From 6de58d7ecbfd14beb7389c6ff56e764b5c00ba25 Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 30 Apr 2024 01:10:20 -0400 Subject: changed acl- and some other field- to acl_ and field_ style --- src/server/authentication/DashUserModel.ts | 4 ++-- src/server/authentication/Passport.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/server') diff --git a/src/server/authentication/DashUserModel.ts b/src/server/authentication/DashUserModel.ts index a288bfeab..bfa6d7bdb 100644 --- a/src/server/authentication/DashUserModel.ts +++ b/src/server/authentication/DashUserModel.ts @@ -61,7 +61,7 @@ const userSchema = new mongoose.Schema( * Password hash middleware. */ userSchema.pre('save', function save(next) { - const user = this as any as DashUserModel; + const user = this; if (!user.isModified('password')) { return next(); } @@ -70,7 +70,7 @@ userSchema.pre('save', function save(next) { return next(err); } bcrypt.hash( - user.password, + user.password ?? '', salt, () => {}, (cryptErr: mongoose.Error, hash: string) => { diff --git a/src/server/authentication/Passport.ts b/src/server/authentication/Passport.ts index a5222e531..ca9e3058e 100644 --- a/src/server/authentication/Passport.ts +++ b/src/server/authentication/Passport.ts @@ -18,11 +18,11 @@ passport.deserializeUser((id, done) => { passport.use( new LocalStrategy({ usernameField: 'email', passReqToCallback: true }, (req, email, password, done) => { User.findOne({ email: email.toLowerCase() }) - .then((user: any) => { + .then((user: DashUserModel) => { if (!user) { done(undefined, false, { message: 'Invalid email or password' }); // invalid email } else { - (user as any as DashUserModel).comparePassword(password, (error: Error, isMatch: boolean) => { + user.comparePassword(password, (error: Error, isMatch: boolean) => { if (error) return done(error); if (!isMatch) return done(undefined, false, { message: 'Invalid email or password' }); // invalid password // valid authentication HERE -- cgit v1.2.3-70-g09d2