fix(ui): initial password reset jwt setup

This commit is contained in:
Shekar Siri 2024-09-03 13:14:29 +05:30
parent 7d3c91ff67
commit 30dc00a3e7
3 changed files with 8 additions and 5 deletions

View file

@ -169,6 +169,7 @@ export default class APIClient {
path.includes('login')
|| path.includes('refresh')
|| path.includes('logout')
|| path.includes('reset')
) && window.env.NODE_ENV !== 'development'
) {
init.credentials = 'include';

View file

@ -22,7 +22,7 @@ export default () => (next) => (action) => {
}
return response.json();
})
.then((json) => json || {}) // TEMP TODO on server: no empty responces
.then((json) => json || {}) // TEMP TODO on server: no empty responses
.then(({ jwt, errors, data }) => {
if (errors) {
next({ type: FAILURE, errors, data });
@ -30,7 +30,7 @@ export default () => (next) => (action) => {
next({ type: SUCCESS, data, ...rest });
}
if (jwt) {
next({ type: UPDATE_JWT, data: jwt });
next({ type: UPDATE_JWT, data: { jwt } });
}
})
.catch(async (e) => {

View file

@ -76,13 +76,15 @@ const reducer = (state = initialState, action = {}) => {
.set('spotJwt', action.data.spotJwt);
case LOGIN.REQUEST:
return state.set('loginRequest', { loading: true, errors: [] });
case RESET_PASSWORD.SUCCESS:
case LOGIN.SUCCESS:
return state
.set('account', Account({ ...action.data.user }))
.set('account', Account({ ...action.data.data.user }))
.set('spotJwt', action.data.spotJwt)
.set('scope', action.data.scope)
.set('scope', action.data.data.scope)
.set('loginRequest', { loading: false, errors: [] });
case RESET_PASSWORD.SUCCESS:
return state
.set('account', Account({ ...action.data.user }))
case UPDATE_PASSWORD.REQUEST:
case UPDATE_PASSWORD.SUCCESS:
return state.set('passwordErrors', List());