Skip to content

Commit b22e34e

Browse files
authored
Set the correct status code in case of an invalid 2factor code. (#26)
1 parent aa9838b commit b22e34e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

core/src/main/java/com/jongsoft/finance/core/exception/StatusException.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public static StatusException notAuthorized(String message) {
3434
return new StatusException(401, message, null);
3535
}
3636

37+
public static StatusException forbidden(String message) {
38+
return new StatusException(403, message, null);
39+
}
40+
3741
public static StatusException internalError(String message) {
3842
return new StatusException(500, message, null);
3943
}

fintrack-api/src/main/java/com/jongsoft/finance/rest/security/MultiFactorResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public MultiFactorResource(
4646
public HttpResponse<?> validateToken(@Valid @Body MultiFactorRequest verification, HttpRequest<?> request) {
4747
var user = currentUserProvider.currentUser();
4848
if (!TwoFactorHelper.verifySecurityCode(user.getSecret(), verification.verificationCode())) {
49-
throw StatusException.notAuthorized("Invalid verification code");
49+
throw StatusException.forbidden("Invalid verification code");
5050
}
5151

5252
var authentication = Authentication.build(

0 commit comments

Comments
 (0)