mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
feat: sync the isVerified state of authed user
This commit is contained in:
@@ -3,4 +3,8 @@ import t from '@/store/types';
|
||||
|
||||
export const setLogin = () => ({ type: t.LOGIN_SUCCESS });
|
||||
export const setLogout = () => ({ type: t.LOGOUT });
|
||||
export const setStoreReset = () => ({ type: t.RESET });
|
||||
export const setStoreReset = () => ({ type: t.RESET });
|
||||
export const setEmailConfirmed = (verified?: boolean) => ({
|
||||
type: t.SET_EMAIL_VERIFIED,
|
||||
action: { verified },
|
||||
});
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// @ts-nocheck
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { PayloadAction, createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import purgeStoredState from 'redux-persist/es/purgeStoredState';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import { isUndefined } from 'lodash';
|
||||
import { getCookie } from '@/utils';
|
||||
import t from '@/store/types';
|
||||
|
||||
@@ -13,6 +14,7 @@ const initialState = {
|
||||
tenantId: getCookie('tenant_id'),
|
||||
userId: getCookie('authenticated_user_id'),
|
||||
locale: getCookie('locale'),
|
||||
verified: true, // Let's be optimistic and assume the user's email is confirmed.
|
||||
errors: [],
|
||||
};
|
||||
|
||||
@@ -32,6 +34,15 @@ const reducerInstance = createReducer(initialState, {
|
||||
state.errors = [];
|
||||
},
|
||||
|
||||
[t.SET_EMAIL_VERIFIED]: (
|
||||
state,
|
||||
payload: PayloadAction<{ verified?: boolean }>,
|
||||
) => {
|
||||
state.verified = !isUndefined(payload.action.verified)
|
||||
? payload.action.verified
|
||||
: true;
|
||||
},
|
||||
|
||||
[t.RESET]: (state) => {
|
||||
purgeStoredState(CONFIG);
|
||||
},
|
||||
|
||||
@@ -7,4 +7,5 @@ export default {
|
||||
LOGOUT: 'LOGOUT',
|
||||
LOGIN_CLEAR_ERRORS: 'LOGIN_CLEAR_ERRORS',
|
||||
RESET: 'RESET',
|
||||
SET_EMAIL_VERIFIED: 'SET_EMAIL_VERIFIED'
|
||||
};
|
||||
Reference in New Issue
Block a user