비밀번호 해시값 다시 반영

This commit is contained in:
2025-12-12 14:20:41 +09:00
parent c50da0bc32
commit f62e73aaaf

View File

@@ -57,9 +57,8 @@ export class AuthService {
if (!user) { if (!user) {
throw new UnauthorizedException('아이디 또는 비밀번호가 틀렸습니다'); //HTTP 401 상태 코드 예외 throw new UnauthorizedException('아이디 또는 비밀번호가 틀렸습니다'); //HTTP 401 상태 코드 예외
} }
// 3. 비밀번호 비교 (bcrypt) - TODO: 나중에 해시 적용 // 3. 비밀번호 비교 (bcrypt)
// const isPasswordValid = await bcrypt.compare(userPassword, user.userPw); const isPasswordValid = await bcrypt.compare(userPassword, user.userPw);
const isPasswordValid = userPassword === user.userPw; // 평문 비교 (임시)
if (!isPasswordValid) { if (!isPasswordValid) {
throw new UnauthorizedException('아이디 또는 비밀번호가 틀렸습니다'); throw new UnauthorizedException('아이디 또는 비밀번호가 틀렸습니다');
} }
@@ -138,13 +137,13 @@ export class AuthService {
} }
// 2. 비밀번호 해싱 (bcrypt) - TODO: 나중에 해시 적용 // 2. 비밀번호 해싱 (bcrypt)
// const saltRounds = parseInt(this.configService.get<string>('BCRYPT_SALT_ROUNDS') || '10', 10); const saltRounds = parseInt(this.configService.get<string>('BCRYPT_SALT_ROUNDS') || '10', 10);
// const hashedPassword = await bcrypt.hash(signupDto.userPassword, saltRounds); const hashedPassword = await bcrypt.hash(signupDto.userPassword, saltRounds);
// 3. 사용자 생성 // 3. 사용자 생성
const newUser = this.userRepository.create({ const newUser = this.userRepository.create({
userId: signupDto.userId, userId: signupDto.userId,
userPw: signupDto.userPassword, // 평문 저장 (임시) userPw: hashedPassword,
userName: signupDto.userName, userName: signupDto.userName,
userPhone: signupDto.userPhone, userPhone: signupDto.userPhone,
userEmail: signupDto.userEmail, userEmail: signupDto.userEmail,
@@ -479,12 +478,12 @@ export class AuthService {
throw new NotFoundException('사용자를 찾을 수 없습니다'); throw new NotFoundException('사용자를 찾을 수 없습니다');
} }
// 3. 새 비밀번호 해싱 - TODO: 나중에 해시 적용 // 3. 새 비밀번호 해싱
// const saltRounds = parseInt(this.configService.get<string>('BCRYPT_SALT_ROUNDS') || '10', 10); const saltRounds = parseInt(this.configService.get<string>('BCRYPT_SALT_ROUNDS') || '10', 10);
// const hashedPassword = await bcrypt.hash(newPassword, saltRounds); const hashedPassword = await bcrypt.hash(newPassword, saltRounds);
// 4. 비밀번호 업데이트 // 4. 비밀번호 업데이트
user.userPw = newPassword; // 평문 저장 (임시) user.userPw = hashedPassword;
await this.userRepository.save(user); await this.userRepository.save(user);
return { return {