nestjs_auth...

This commit is contained in:
최준흠 2022-09-15 17:26:51 +09:00
parent 32ffb17486
commit 9427680b5b
3 changed files with 5 additions and 8 deletions

View File

@ -34,6 +34,7 @@ export class AuthController {
//사용자 등록
@Post('register')
async add(@Body() data: UserDTO) {
return await this.authService.register(data)
const user = await this.authService.register(data)
return await this.authService.login(user)
}
}

View File

@ -25,11 +25,7 @@ export class AuthService {
}
//app.controller.ts에서 AuthGuard('local') 또는 AuthGuard('jwt')용
async validateUser(where: Prisma.UserWhereInput): Promise<any> {
try {
await this.userService.fetchOne(where)
} catch (e) {
throw new UnauthorizedException('계정 확인이 되지 않습니다.')
}
return await this.userService.fetchOne(where)
}
async login(user: User): Promise<any> {
@ -41,7 +37,7 @@ export class AuthService {
async register(data: UserDTO): Promise<any> {
data.refresh_token = await this.getRefreshToken(data)
data.password = await this.getEcryptedPassword(data.password)
return await this.login(await this.userService.add(data))
return await this.userService.add(data)
}
//Access Token 재발행

View File

@ -23,7 +23,7 @@ export class LocalStrategy extends PassportStrategy(Strategy) {
password: encryptedPassword
})
} catch (e) {
throw new UnauthorizedException(e)
throw new UnauthorizedException('계정 확인이 되지 않습니다.')
}
}
}