aboutsummaryrefslogtreecommitdiff
path: root/src/server/authentication
diff options
context:
space:
mode:
authorSkitty1238 <157652284+Skitty1238@users.noreply.github.com>2025-06-04 22:33:19 -0400
committerSkitty1238 <157652284+Skitty1238@users.noreply.github.com>2025-06-04 22:33:19 -0400
commitc86bf5cc03d6fa59fbc11118d4e743d4c3064697 (patch)
tree2e23a7090046a9f83e7b55feb5b19804348ac1e3 /src/server/authentication
parent745784b36e0f6fd2557ffe0d32cf11051627b148 (diff)
parent55d1653c0d6c19bddefb9e57753374d43d8f23dc (diff)
Merge branch 'task_nodes_aarav' of https://github.com/brown-dash/Dash-Web into task_nodes_aarav
Diffstat (limited to 'src/server/authentication')
-rw-r--r--src/server/authentication/DashUserModel.ts14
-rw-r--r--src/server/authentication/Passport.ts6
2 files changed, 11 insertions, 9 deletions
diff --git a/src/server/authentication/DashUserModel.ts b/src/server/authentication/DashUserModel.ts
index debeef60c..6fd8dd593 100644
--- a/src/server/authentication/DashUserModel.ts
+++ b/src/server/authentication/DashUserModel.ts
@@ -2,9 +2,10 @@ import * as bcrypt from 'bcrypt-nodejs';
import * as mongoose from 'mongoose';
import { Utils } from '../../Utils';
-type comparePasswordFunction = (candidatePassword: string, cb: (err: any, isMatch: any) => void) => void;
-export type DashUserModel = mongoose.Document & {
- email: String;
+type comparePasswordFunction = (candidatePassword: string, cb: (err: Error, isMatch: boolean) => void) => void;
+type mongooseDocument = { id: string }; // & mongoose.Document;
+export type DashUserModel = mongooseDocument & {
+ email: string;
password: string;
passwordResetToken?: string;
passwordResetExpires?: Date;
@@ -65,12 +66,13 @@ const userSchema = new mongoose.Schema(
/**
* Password hash middleware.
*/
-userSchema.pre('save', function save(next) {
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+userSchema.pre('save', function save(next: any) {
const user = this;
if (!user.isModified('password')) {
return next();
}
- bcrypt.genSalt(10, (err: any, salt: string) => {
+ bcrypt.genSalt(10, (err: Error, salt: string) => {
if (err) {
return next(err);
}
@@ -102,7 +104,7 @@ const comparePassword: comparePasswordFunction = function (this: DashUserModel,
userSchema.methods.comparePassword = comparePassword;
-const User: any = mongoose.model('User', userSchema);
+const User = mongoose.model('User', userSchema);
export function initializeGuest() {
new User({
email: 'guest',
diff --git a/src/server/authentication/Passport.ts b/src/server/authentication/Passport.ts
index ca9e3058e..a62d38e3e 100644
--- a/src/server/authentication/Passport.ts
+++ b/src/server/authentication/Passport.ts
@@ -5,13 +5,13 @@ import User, { DashUserModel } from './DashUserModel';
const LocalStrategy = passportLocal.Strategy;
passport.serializeUser<any, any>((req, user, done) => {
- done(undefined, (user as any)?.id);
+ done(undefined, (user as DashUserModel)?.id);
});
passport.deserializeUser<any, any>((id, done) => {
User.findById(id)
.exec()
- .then((user: any) => done(undefined, user));
+ .then((user: DashUserModel) => done(undefined, user));
});
// AUTHENTICATE JUST WITH EMAIL AND PASSWORD
@@ -30,6 +30,6 @@ passport.use(
});
}
})
- .catch((error: any) => done(error));
+ .catch((error: Error) => done(error));
})
);