From 7a146e21fe01e3749e1a0b2be6f6c62ae59fc884 Mon Sep 17 00:00:00 2001 From: Roman Strobl Date: Mon, 3 Jan 2022 22:44:03 +0100 Subject: [PATCH] Fix #1072: Failed input validations not processed correctly --- .../exception/AuthenticationExceptionResolver.java | 2 +- .../src/main/js/actions/loginScaActions.js | 13 +++++++++++++ .../src/main/js/actions/smsAuthActions.js | 13 +++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/powerauth-webflow-authentication/src/main/java/io/getlime/security/powerauth/lib/webflow/authentication/exception/AuthenticationExceptionResolver.java b/powerauth-webflow-authentication/src/main/java/io/getlime/security/powerauth/lib/webflow/authentication/exception/AuthenticationExceptionResolver.java index 2bb94e1cb..6ee8e2dcf 100644 --- a/powerauth-webflow-authentication/src/main/java/io/getlime/security/powerauth/lib/webflow/authentication/exception/AuthenticationExceptionResolver.java +++ b/powerauth-webflow-authentication/src/main/java/io/getlime/security/powerauth/lib/webflow/authentication/exception/AuthenticationExceptionResolver.java @@ -70,7 +70,7 @@ public AuthenticationExceptionResolver(Audit audit) { */ @ExceptionHandler(AuthStepException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) - public @ResponseBody ErrorResponse handleMethodNotValidException(AuthStepException ex) { + public @ResponseBody ErrorResponse handleAuthStepException(AuthStepException ex) { logger.warn("Error occurred in Web Flow server: {}", ex.getMessage()); audit.warn("Error occurred in Web Flow server: {}", AUDIT_DETAIL_BAD_REQUEST, ex); // Web Flow returns message ID for front-end localization instead of message. diff --git a/powerauth-webflow/src/main/js/actions/loginScaActions.js b/powerauth-webflow/src/main/js/actions/loginScaActions.js index 980f05118..b40c84e18 100644 --- a/powerauth-webflow/src/main/js/actions/loginScaActions.js +++ b/powerauth-webflow/src/main/js/actions/loginScaActions.js @@ -89,6 +89,19 @@ export function authenticate(username, organizationId) { } return null; }).catch((error) => { + // Handle request validation errors + if (error.response.status === 400 && error.response.data.message !== undefined) { + dispatch({ + type: "SHOW_SCREEN_LOGIN_SCA", + payload: { + loading: false, + error: true, + message: error.response.data.message, + remainingAttempts: error.response.data.remainingAttempts + } + }); + return; + } dispatchError(dispatch, error); }) } diff --git a/powerauth-webflow/src/main/js/actions/smsAuthActions.js b/powerauth-webflow/src/main/js/actions/smsAuthActions.js index 539160a07..b4db6f40c 100644 --- a/powerauth-webflow/src/main/js/actions/smsAuthActions.js +++ b/powerauth-webflow/src/main/js/actions/smsAuthActions.js @@ -212,6 +212,19 @@ export function authenticate(userAuthCode, userPassword, component) { } return null; }).catch((error) => { + // Handle request validation errors + if (error.response.status === 400 && error.response.data.message !== undefined) { + dispatch({ + type: getActionType(component), + payload: { + loading: false, + error: true, + message: error.response.data.message, + remainingAttempts: error.response.data.remainingAttempts + } + }); + return; + } dispatchError(dispatch, error); }) }