nestjs_auth...

This commit is contained in:
최준흠 2022-09-12 11:45:50 +09:00
parent 3a3b2bd1b0
commit 3ee53b2992
2 changed files with 5 additions and 5 deletions

View File

@ -41,7 +41,7 @@ export class AuthService {
async register(data: UserDTO): Promise<any | null> { async register(data: UserDTO): Promise<any | null> {
const tokens = await this.getTokens(data) const tokens = await this.getTokens(data)
data.refresh_key = tokens['refresh-token'] data.refresh_token = tokens['refresh_token']
const encryptedPassword = await this.getEcryptedPassword(data.password) const encryptedPassword = await this.getEcryptedPassword(data.password)
data.password = encryptedPassword data.password = encryptedPassword
const user = await this.userService.add(data) const user = await this.userService.add(data)
@ -53,7 +53,7 @@ export class AuthService {
const tokens = await this.getTokens(user) const tokens = await this.getTokens(user)
await this.userService.update({ await this.userService.update({
where: { id: user.id }, where: { id: user.id },
data: { refresh_token: tokens['refresh-token'] } data: { refresh_token: tokens['refresh_token'] }
}) })
return tokens return tokens
} }
@ -76,6 +76,6 @@ export class AuthService {
} }
) )
]) ])
return { 'access-token': accessToken, 'refresh-token': refreshToken } return { access_token: accessToken, refresh_token: refreshToken }
} }
} }

View File

@ -1,11 +1,11 @@
import { ROLE, User } from '@prisma/client' import { ROLE } from '@prisma/client'
export class UserDTO { export class UserDTO {
email: string email: string
password: string password: string
name: string name: string
role?: ROLE | 'USER' role?: ROLE | 'USER'
refresh_key?: string refresh_token?: string
is_done?: boolean | false is_done?: boolean | false
updatedAt?: Date | null updatedAt?: Date | null
createdAt?: Date createdAt?: Date