Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

created user flag option #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

created user flag option #16

wants to merge 3 commits into from

Conversation

dee-kryvenko
Copy link
Member

No description provided.

@@ -4,6 +4,7 @@ module.exports = function (passport, passportHelpers, models, moment, BasicStrat

let UserAuthToken = models.userAuthToken;
let User = models.user;
let flag = User.flag;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed

@@ -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);
Copy link
Member Author

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);

@@ -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}
Copy link
Member Author

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}

Copy link
Member Author

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

});

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) {
Copy link
Member Author

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

return new User({
username: username,
password: password,
email: email,
name: name,
avatar: avatar,
roles: [defaultRole]
roles: [defaultRole],
flag : {type: boolean, required: true}
Copy link
Member Author

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}
Copy link
Member Author

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,) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing , should be removed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants