Skip to content

Commit

Permalink
Intermediate change to shim permissions into User model
Browse files Browse the repository at this point in the history
  • Loading branch information
bmajewski committed Feb 25, 2015
1 parent 8a19651 commit 88039a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/models/user.js
Expand Up @@ -5,7 +5,8 @@ var Schema = mongoose.Schema;
var UserSchema = new Schema({
name: String,
email: {type: String, required: true, index: {unique: true}},
password: {type: String, required: true, select: false}
password: {type: String, required: true, select: false},
permissions: [String]
});

module.exports = mongoose.model('User', UserSchema);
10 changes: 8 additions & 2 deletions app/routes/user.js
Expand Up @@ -14,6 +14,7 @@ module.exports = function (app, express) {
user.name = req.body.name;
user.email = req.body.email;
user.password = req.body.password;
user.permissions = req.query.permissions || [];

user.save(function (err) {
if (err) {
Expand Down Expand Up @@ -51,10 +52,15 @@ module.exports = function (app, express) {
if (req.body.name) user.name = req.body.name;
if (req.body.email) user.email = req.body.email;
if (req.body.password) user.password = req.body.password;
user.permissions = req.query.permissions || [];


user.save(function (err) {
if (err)res.send(err);
res.json(user);
if (err) {
res.send(err);
} else {
res.json(user);
}
});
});
})
Expand Down

0 comments on commit 88039a9

Please sign in to comment.