diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 18ff5eb..365f79d 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -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) } } diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 9a1a370..cb79120 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -25,11 +25,7 @@ export class AuthService { } //app.controller.ts에서 AuthGuard('local') 또는 AuthGuard('jwt')용 async validateUser(where: Prisma.UserWhereInput): Promise { - try { - await this.userService.fetchOne(where) - } catch (e) { - throw new UnauthorizedException('계정 확인이 되지 않습니다.') - } + return await this.userService.fetchOne(where) } async login(user: User): Promise { @@ -41,7 +37,7 @@ export class AuthService { async register(data: UserDTO): Promise { 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 재발행 diff --git a/src/auth/guards/local.strategy.ts b/src/auth/guards/local.strategy.ts index e48f834..fa7083a 100644 --- a/src/auth/guards/local.strategy.ts +++ b/src/auth/guards/local.strategy.ts @@ -23,7 +23,7 @@ export class LocalStrategy extends PassportStrategy(Strategy) { password: encryptedPassword }) } catch (e) { - throw new UnauthorizedException(e) + throw new UnauthorizedException('계정 확인이 되지 않습니다.') } } }