diff options
| author | Andrew Kim <andrewdkim@users.noreply.github.com> | 2019-04-20 18:42:01 -0400 |
|---|---|---|
| committer | Andrew Kim <andrewdkim@users.noreply.github.com> | 2019-04-20 18:42:01 -0400 |
| commit | 840de58f003d0962ef7d3a0ad6ea284d1f4870db (patch) | |
| tree | 32377ecaedceb24e54b6645ae76f3a5e0171fd54 /src/server/authentication/models/user_model.ts | |
| parent | 604d20941837fa90c06a7da7e77a27c262cd4648 (diff) | |
| parent | e47656cdc18aa1fd801a3853fa0f819140a68646 (diff) | |
update
Diffstat (limited to 'src/server/authentication/models/user_model.ts')
| -rw-r--r-- | src/server/authentication/models/user_model.ts | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/server/authentication/models/user_model.ts b/src/server/authentication/models/user_model.ts index 1c6926517..ee85e1c05 100644 --- a/src/server/authentication/models/user_model.ts +++ b/src/server/authentication/models/user_model.ts @@ -18,8 +18,8 @@ mongoose.connection.on('disconnected', function () { export type DashUserModel = mongoose.Document & { email: string, password: string, - passwordResetToken: string | undefined, - passwordResetExpires: Date | undefined, + passwordResetToken?: string, + passwordResetExpires?: Date, userDocumentId: string; @@ -67,11 +67,17 @@ const userSchema = new mongoose.Schema({ */ userSchema.pre("save", function save(next) { const user = this as DashUserModel; - if (!user.isModified("password")) { return next(); } + if (!user.isModified("password")) { + return next(); + } bcrypt.genSalt(10, (err, salt) => { - if (err) { return next(err); } + if (err) { + return next(err); + } bcrypt.hash(user.password, salt, () => void {}, (err: mongoose.Error, hash) => { - if (err) { return next(err); } + if (err) { + return next(err); + } user.password = hash; next(); }); @@ -79,9 +85,7 @@ userSchema.pre("save", function save(next) { }); const comparePassword: comparePasswordFunction = function (this: DashUserModel, candidatePassword, cb) { - bcrypt.compare(candidatePassword, this.password, (err: mongoose.Error, isMatch: boolean) => { - cb(err, isMatch); - }); + bcrypt.compare(candidatePassword, this.password, cb); }; userSchema.methods.comparePassword = comparePassword; |
