Initial commit

This commit is contained in:
Jakob Kordež
2023-09-04 22:10:54 +02:00
commit f24d39b4e1
59 changed files with 9378 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import { Strategy } from 'passport-local';
import { PassportStrategy } from '@nestjs/passport';
import { Injectable, UnauthorizedException } from '@nestjs/common';
import { AuthService } from '../auth.service';
@Injectable()
export class LocalStrategy extends PassportStrategy(Strategy) {
constructor(private authService: AuthService) {
super();
}
async validate(username: string, password: string): Promise<any> {
const user = await this.authService.validateUser(username, password);
if (!user) throw new UnauthorizedException();
return user;
}
}