aboutsummaryrefslogtreecommitdiff
path: root/src/server/authentication/models/user_model.ts
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-04-14 19:44:38 -0400
committerBob Zeleznik <zzzman@gmail.com>2019-04-14 19:44:38 -0400
commit845057ef78f272faf488b5bbc2fe79d64fb64120 (patch)
tree2ce621b59b3ab80d3ca95d4ee16b58c72548417c /src/server/authentication/models/user_model.ts
parent7f0b7a3e02d2d5ea3bd9f8554f1828d0470b1d04 (diff)
mostly northstar cleanup, plus cleaning up main.tsx
Diffstat (limited to 'src/server/authentication/models/user_model.ts')
-rw-r--r--src/server/authentication/models/user_model.ts21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/server/authentication/models/user_model.ts b/src/server/authentication/models/user_model.ts
index 1c6926517..d5c84c311 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,8 @@ 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, (err: mongoose.Error, isMatch: boolean) =>
+ cb(err, isMatch));
};
userSchema.methods.comparePassword = comparePassword;