add remember me functionality

This commit is contained in:
2023-08-04 13:21:18 +02:00
parent 582c2885ed
commit c4d344f07d
2 changed files with 11 additions and 6 deletions

View File

@@ -9,11 +9,13 @@ export class LocalStrategy extends PassportStrategy(Strategy) {
constructor(private readonly authService: AuthService) {
super({
usernameField: 'email',
passReqToCallback: true,
})
}
async validate(email: string, password: string): Promise<any> {
const newCredentials = await this.authService.checkCredentials(email, password)
async validate(req: any, email: string, password: string): Promise<any> {
const rememberMe = req?.body?.rememberMe || false
const newCredentials = await this.authService.checkCredentials(email, password, rememberMe)
if (newCredentials.resultCode === 1) {
throw new UnauthorizedException('Invalid credentials')