From d1640db394738c08d95b11ca16f3b6b004283324 Mon Sep 17 00:00:00 2001 From: Arnab Dutta Date: Fri, 8 Mar 2024 19:05:54 +0530 Subject: [PATCH] feat: enable dialog for password which is not following rule #1593 Signed-off-by: Arnab Dutta --- .../user-management/redux/sagas/UserSaga.js | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/admin-ui/plugins/user-management/redux/sagas/UserSaga.js b/admin-ui/plugins/user-management/redux/sagas/UserSaga.js index 83eb042cd..c8fa7df6a 100644 --- a/admin-ui/plugins/user-management/redux/sagas/UserSaga.js +++ b/admin-ui/plugins/user-management/redux/sagas/UserSaga.js @@ -47,7 +47,8 @@ export function* createUserSaga({ payload }) { yield* triggerWebhook({ payload: { createdFeatureValue: data } }) return data } catch (e) { - yield put(updateToast(true, 'error')) + const errMsg = e?.response?.body?.description || e?.response?.text + yield* errorToast(errMsg) yield put(createUserResponse(null)) if (isFourZeroOneError(e)) { const jwt = yield select((state) => state.authReducer.userinfo_jwt) @@ -67,7 +68,8 @@ export function* updateUserSaga({ payload }) { yield* triggerWebhook({ payload: { createdFeatureValue: data } }) return data } catch (e) { - yield put(updateToast(true, 'error')) + const errMsg = e?.response?.body?.description || e?.response?.text + yield* errorToast(errMsg) yield put(updateUserResponse(null)) if (isFourZeroOneError(e)) { const jwt = yield select((state) => state.authReducer.userinfo_jwt) @@ -86,7 +88,8 @@ export function* changeUserPasswordSaga({ payload }) { yield put(updateToast(true, 'success')) yield put(changeUserPasswordResponse(data)) } catch (e) { - yield put(updateToast(true, 'error')) + const errMsg = e?.response?.body?.description || e?.response?.text + yield* errorToast(errMsg) yield put(changeUserPasswordResponse(null)) if (isFourZeroOneError(e)) { const jwt = yield select((state) => state.authReducer.userinfo_jwt) @@ -105,7 +108,8 @@ export function* getUsersSaga({ payload }) { yield call(postUserAction, audit) return data } catch (e) { - yield put(getUserResponse(null)) + const errMsg = e?.response?.body?.description || e?.response?.text + yield* errorToast(errMsg) if (isFourZeroOneError(e)) { const jwt = yield select((state) => state.authReducer.userinfo_jwt) yield put(getAPIAccessToken(jwt)) @@ -126,7 +130,8 @@ export function* deleteUserSaga({ payload }) { yield* triggerWebhook({ payload: { createdFeatureValue: payload } }) return data } catch (e) { - yield put(updateToast(true, 'error')) + const errMsg = e?.response?.body?.description || e?.response?.text + yield* errorToast(errMsg) yield put(deleteUserResponse(null)) if (isFourZeroOneError(e)) { const jwt = yield select((state) => state.authReducer.userinfo_jwt) @@ -136,6 +141,16 @@ export function* deleteUserSaga({ payload }) { } } +function* errorToast(errMsg) { + yield put( + updateToast( + true, + 'error', + errMsg + ) + ) +} + export function* watchGetUsers() { yield takeEvery('user/getUsers', getUsersSaga) }