nestjs_auth...
This commit is contained in:
parent
c21837ada5
commit
3d83b897ce
@ -19,7 +19,7 @@ export class AuthService {
|
||||
// return await bcrypt
|
||||
// .hash(password, jwtConstants.password_saltorRounds)
|
||||
// .catch((e) => {
|
||||
// new Error('암호화 실패' + e)
|
||||
// throw new Error('암호화 실패' + e)
|
||||
// })
|
||||
return password
|
||||
}
|
||||
@ -28,7 +28,7 @@ export class AuthService {
|
||||
const user = await this.userService
|
||||
.fetchOne({ email: email })
|
||||
.catch((error) => {
|
||||
new UnauthorizedException('사용자를 찾을 수 없습니다.' + error)
|
||||
throw new UnauthorizedException('사용자를 찾을 수 없습니다.' + error)
|
||||
})
|
||||
const encryptedPassword = await this.getEcryptedPassword(password)
|
||||
if (user && user.password === encryptedPassword) {
|
||||
@ -36,7 +36,7 @@ export class AuthService {
|
||||
const { password, ...result } = user
|
||||
return result
|
||||
} else {
|
||||
new UnauthorizedException('암호가 맞지 않습니다.')
|
||||
throw new UnauthorizedException('암호가 맞지 않습니다.')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,8 @@ export class LocalStrategy extends PassportStrategy(Strategy) {
|
||||
try {
|
||||
return await this.authService.validateUser(email, password)
|
||||
} catch (e) {
|
||||
new UnauthorizedException(e.message)
|
||||
console.log(e)
|
||||
throw new UnauthorizedException(e.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ export class UserService {
|
||||
}
|
||||
|
||||
//단일 조회
|
||||
async fetchOne(where: Prisma.UserWhereInput): Promise<User | null> {
|
||||
async fetchOne(where: Prisma.UserWhereInput): Promise<User> {
|
||||
return await this.prisma.user.findFirstOrThrow({ where: where })
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ export class UserService {
|
||||
async update(params: {
|
||||
where: Prisma.UserWhereUniqueInput
|
||||
data: Prisma.UserUpdateInput
|
||||
}): Promise<User | null> {
|
||||
}): Promise<User> {
|
||||
const { where, data } = params
|
||||
return await this.prisma.user.update({
|
||||
data,
|
||||
@ -65,7 +65,7 @@ export class UserService {
|
||||
}
|
||||
|
||||
//단일 삭제
|
||||
async remove(where: Prisma.UserWhereUniqueInput): Promise<User | null> {
|
||||
async remove(where: Prisma.UserWhereUniqueInput) {
|
||||
return await this.prisma.user.delete({ where })
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user