Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User accepts empty password #2

Open
andre-luis opened this issue Jun 5, 2014 · 0 comments
Open

User accepts empty password #2

andre-luis opened this issue Jun 5, 2014 · 0 comments

Comments

@andre-luis
Copy link

Maybe it is intended, but I think it is a problem to let user set his password to an empty string without even warning. In my app, I do not let him do it, so when he sends an empty password, the document do not validate. The implementation is very basic, based on the idea that if a empty password is passed, the schema do not set hashed_password. Something like this:

schema.virtual('password')
.set(function (password) {
if (password.trim().length) { // this line is new
this._password = password;
this.salt = this.makeSalt();
this.hashed_password = this.encryptPassword(password);
} // and this one, also
})
.get(function() {
return this._password;
});

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

No branches or pull requests

1 participant