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