-
Notifications
You must be signed in to change notification settings - Fork 0
created user flag option #16
base: master
Are you sure you want to change the base?
Conversation
app/config/passport.js
Outdated
@@ -4,6 +4,7 @@ module.exports = function (passport, passportHelpers, models, moment, BasicStrat | |||
|
|||
let UserAuthToken = models.userAuthToken; | |||
let User = models.user; | |||
let flag = User.flag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed
app/config/passport.js
Outdated
@@ -16,6 +17,7 @@ module.exports = function (passport, passportHelpers, models, moment, BasicStrat | |||
}, function (err, user) { | |||
if (err) return done(err); | |||
if (!user) return done(null, false); | |||
if (flag = false) return done(null, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!user.flag) return done(null, false);
app/models/user.js
Outdated
@@ -10,21 +10,23 @@ module.exports = function (modelHelpers, connection, mongoose) { | |||
email: {type: String, required: true}, | |||
name: {type: String, required: true}, | |||
avatar: String, | |||
roles: [{type: mongoose.Schema.Types.ObjectId, ref: 'UserRole'}] | |||
roles: [{type: mongoose.Schema.Types.ObjectId, ref: 'UserRole'}], | |||
flag : {type: boolean} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flag: {type: boolean, required: true, default: false}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please let's change name of this field to something that makes sense, for instance isActivated
app/models/user.js
Outdated
}); | ||
|
||
userSchema.methods.toString = function () { | ||
return this.username; | ||
}; | ||
|
||
userSchema.statics.generateNew = function (username, password, email, name, avatar, defaultRole) { | ||
userSchema.statics.generateNew = function (username, password, email, name, avatar, defaultRole, flag) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed we don't need this flag to be passed outside, we know it should be false
by default
app/models/user.js
Outdated
return new User({ | ||
username: username, | ||
password: password, | ||
email: email, | ||
name: name, | ||
avatar: avatar, | ||
roles: [defaultRole] | ||
roles: [defaultRole], | ||
flag : {type: boolean, required: true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flag: false
@@ -10,21 +10,23 @@ module.exports = function (modelHelpers, connection, mongoose) { | |||
email: {type: String, required: true}, | |||
name: {type: String, required: true}, | |||
avatar: String, | |||
roles: [{type: mongoose.Schema.Types.ObjectId, ref: 'UserRole'}] | |||
roles: [{type: mongoose.Schema.Types.ObjectId, ref: 'UserRole'}], | |||
emailConfirmed : {type: boolean} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be emailConfirmed: {type: boolean, required: true, default: false}
}); | ||
|
||
userSchema.methods.toString = function () { | ||
return this.username; | ||
}; | ||
|
||
userSchema.statics.generateNew = function (username, password, email, name, avatar, defaultRole) { | ||
userSchema.statics.generateNew = function (username, password, email, name, avatar, defaultRole,) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing ,
should be removed
No description provided.