Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 1x 1x 1x 1x 1x 15x 15x 16x 15x 8x 7x | import { Injectable, UnauthorizedException } from "@nestjs/common"; import { PassportStrategy } from "@nestjs/passport"; import { Strategy } from "passport-local"; import { AuthService } from "../auth.service"; import { User } from "../../users/user.entity"; @Injectable() export class LocalStrategy extends PassportStrategy(Strategy) { constructor(private readonly authService: AuthService) { super({ usernameField: "email", // 이메일을 username 필드로 사용 }); } async validate(email: string, password: string): Promise<User> { const user = await this.authService.validateUser(email, password); if (!user) { throw new UnauthorizedException("Invalid credentials"); } return user; } } |