From 227bcda4e5f11068d3de62c2a9dab55554b17bbb Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Wed, 8 Feb 2023 17:42:53 +0100 Subject: [PATCH] change(ui) - show login errors from API --- frontend/app/components/Login/Login.js | 2 +- frontend/app/duck/user.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/app/components/Login/Login.js b/frontend/app/components/Login/Login.js index 4e628917d..7270944d1 100644 --- a/frontend/app/components/Login/Login.js +++ b/frontend/app/components/Login/Login.js @@ -129,7 +129,7 @@ class Login extends React.Component { - {errors.length ? ( + {errors && errors.length ? (
{errors.map((error) => (
diff --git a/frontend/app/duck/user.js b/frontend/app/duck/user.js index 691e72e41..c2c149de5 100644 --- a/frontend/app/duck/user.js +++ b/frontend/app/duck/user.js @@ -30,6 +30,7 @@ export const initialState = Map({ onboarding: false, sites: List(), jwt: null, + errors: List(), loginRequest: { loading: false, errors: [] @@ -77,8 +78,9 @@ const reducer = (state = initialState, action = {}) => { case UPDATE_PASSWORD.FAILURE: return state.set('passwordErrors', List(action.errors)) case LOGIN.FAILURE: + console.log('login failed', action); deleteCookie('jwt', '/', 'openreplay.com') - return state.set('loginRequest', { loading: false, errors: ['Invalid username or password'] }); + return state.set('loginRequest', { loading: false, errors: action.errors }); case FETCH_ACCOUNT.FAILURE: case DELETE.SUCCESS: case DELETE.FAILURE: @@ -100,6 +102,7 @@ const reducer = (state = initialState, action = {}) => { export default withRequestState({ signupRequest: SIGNUP, + // loginRequest: LOGIN, updatePasswordRequest: UPDATE_PASSWORD, requestResetPassowrd: REQUEST_RESET_PASSWORD, resetPassword: RESET_PASSWORD,