Skip to content

Commit 08825bf

Browse files
committed
bugfix: validate-code with wrong code returns 200 code
1 parent df4e504 commit 08825bf

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

rentplace/src/main/java/kattsyn/dev/rentplace/services/impl/AuthServiceImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ private JwtResponse getJwtResponse(User user, String email, String code, HttpSer
9090
}
9191

9292
@Override
93-
public void validateCode(JwtRequest request) {
94-
verificationCodeService.validateCode(request.getEmail(), request.getCode());
93+
public void validateCode(JwtRequest request) throws AuthException {
94+
if (!verificationCodeService.validateCode(request.getEmail(), request.getCode())) {
95+
throw new AuthException("Код неверный");
96+
}
9597
}
9698

9799
public JwtResponse getAccessToken(@NonNull String refreshToken, HttpServletRequest httpServletRequest) {

rentplace/src/main/java/kattsyn/dev/rentplace/services/impl/VerificationCodeServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class VerificationCodeServiceImpl implements VerificationCodeService {
2323
@Override
2424
public boolean validateCode(String email, String code) {
2525
VerificationCode verificationCode = verificationCodeRepository.findById(email)
26-
.orElseThrow(() -> new NotFoundException(String.format("Verification code with email %s not found", email)));
26+
.orElseThrow(() -> new NotFoundException(String.format("Код верификации для почты: %s не найден", email)));
2727

2828
return verificationCode.getCode().equals(code);
2929
}

0 commit comments

Comments
 (0)