Commit 0e979e43 authored by Kim, Subin's avatar Kim, Subin
Browse files

Merge remote-tracking branch 'origin/NewMaster' into kimpen

parents 7393930d 32dcbf22
This diff is collapsed.
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject" "eject": "react-scripts eject"
}, },
"proxy": "http://localhost:3030",
"eslintConfig": { "eslintConfig": {
"extends": "react-app" "extends": "react-app"
}, },
...@@ -38,6 +39,5 @@ ...@@ -38,6 +39,5 @@
"last 1 firefox version", "last 1 firefox version",
"last 1 safari version" "last 1 safari version"
] ]
}, }
"proxy": "http://localhost:3030"
} }
...@@ -26,18 +26,6 @@ ReactDOM.render( ...@@ -26,18 +26,6 @@ ReactDOM.render(
document.getElementById('root') document.getElementById('root')
); );
// ReactDOM.render(
// <Router>
// <Switch>
// <Route exact path="/" component={Login} />
// <Route path="/home" component={Home} />
// </Switch>
// </Router>,
// document.getElementById('root')
// );
// If you want your app to work offline and load faster, you can change // If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls. // unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA // Learn more about service workers: https://bit.ly/CRA-PWA
......
const mongoose = require('mongoose'); const mongoose = require('mongoose');
const bcrypt = require("bcrypt");
const saltRounds = 10;
const { Schema } = mongoose; const { Schema } = mongoose;
const userSchema = new Schema({ const userSchema = new Schema({
id : { name: {
type: Number,
unique: true,
},
password : {
type: String, type: String,
required: true,
}, },
name : { password: {
type: String, type: String,
}
},
id: {
type: Number,
required: true,
},
}); });
userSchema.pre("save", function (next) {
let user = this; //User모델 자체를 가르킴.
//model 안의 paswsword가 변경 또는 생성될 때 암호화
if (user.isModified("password")) {
bcrypt.genSalt(saltRounds, function (err, salt) {
if (err) return next(err);
bcrypt.hash(user.password, salt, function (err, hash) {
if (err) return next(err);
user.password = hash;
next();
});
});
} else {
next();
}
});
module.exports = mongoose.model('User', userSchema); module.exports = mongoose.model('User', userSchema);
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment