src/module/auth/strategy/local.strategy.ts
Methods |
|
constructor(authService: AuthService)
|
||||||
Defined in src/module/auth/strategy/local.strategy.ts:7
|
||||||
Parameters :
|
Async validate |
validate(username: string, password: string)
|
Returns :
Promise<any>
|
import { Strategy } from 'passport-local';
import { PassportStrategy } from '@nestjs/passport';
import { Injectable } from '@nestjs/common';
import { AuthService } from '../service/auth.service';
@Injectable()
export class LocalStrategy extends PassportStrategy(Strategy) {
constructor(private readonly authService: AuthService) {
super({
usernameField: 'email'
});
}
async validate(username: string, password: string): Promise<any> {
return await this.authService.authenticate(username, password);
}
}