fix: adapt passport logic

This commit is contained in:
yassinedorbozgithub 2025-01-09 08:46:45 +01:00
parent 88cb281694
commit cc2f5a1665

View File

@ -19,7 +19,10 @@ export class AuthSerializer extends PassportSerializer {
super();
}
serializeUser(user: User, done: (err: Error, user: SessionUser) => void) {
serializeUser(
user: User,
done: (err: Error | null, user: SessionUser) => void,
) {
done(null, {
id: user.id,
first_name: user.first_name,
@ -29,9 +32,9 @@ export class AuthSerializer extends PassportSerializer {
async deserializeUser(
payload: SessionUser,
done: (err: Error, user: SessionUser) => void,
done: (err: Error | null, user: SessionUser | null) => void,
) {
const user = await this.userService.findOne(payload.id);
const user = payload.id ? await this.userService.findOne(payload.id) : null;
user ? done(null, user) : done(null, null);
}
}