fix: Showing the real mail address on email confirmation view (#445)

* fix: Showing the real mail address on email confirmation view

* chore: remove the unused hook
This commit is contained in:
Ahmed Bouhuolia
2024-05-15 14:03:58 +02:00
committed by GitHub
parent 370a8a4b91
commit e380c598d3
8 changed files with 164 additions and 22 deletions

View File

@@ -4,7 +4,27 @@ 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 setEmailConfirmed = (verified?: boolean) => ({
export const setEmailConfirmed = (verified?: boolean, email?: string) => ({
type: t.SET_EMAIL_VERIFIED,
action: { verified },
action: { verified, email },
});
export const setOrganizationId = (organizationId: string) => ({
type: t.SET_ORGANIZATIOIN_ID,
action: { organizationId },
});
export const setAuthToken = (token: string) => ({
type: t.SET_AUTH_TOKEN,
action: { token },
});
export const setAuthTenantId = (tenantId: string) => ({
type: t.SET_TENANT_ID,
action: { tenantId },
});
export const setAuthUserId = (userId: string) => ({
type: t.SET_USER_ID,
action: { userId },
});
export const setLocale = (locale: string) => ({
type: t.SET_LOCALE,
action: { locale },
});

View File

@@ -9,12 +9,13 @@ import t from '@/store/types';
// Read stored data in cookies and merge it with the initial state.
const initialState = {
token: getCookie('token'),
organizationId: getCookie('organization_id'),
tenantId: getCookie('tenant_id'),
userId: getCookie('authenticated_user_id'),
locale: getCookie('locale'),
token: getCookie('token') || null,
organizationId: getCookie('organization_id') || null,
tenantId: getCookie('tenant_id') || null,
userId: getCookie('authenticated_user_id') || null,
locale: getCookie('locale') || 'en',
verified: true, // Let's be optimistic and assume the user's email is confirmed.
verifyEmail: null,
errors: [],
};
@@ -36,11 +37,35 @@ const reducerInstance = createReducer(initialState, {
[t.SET_EMAIL_VERIFIED]: (
state,
payload: PayloadAction<{ verified?: boolean }>,
payload: PayloadAction<{ verified?: boolean; email?: string }>,
) => {
state.verified = !isUndefined(payload.action.verified)
? payload.action.verified
: true;
state.verifyEmail = payload.action.email || null;
if (state.verified) {
state.verifyEmail = null;
}
},
[t.SET_AUTH_TOKEN]: (state, payload: PayloadAction<{ token: string }>) => {
state.token = payload.action.token;
},
[t.SET_ORGANIZATIOIN_ID]: (
state,
payload: PayloadAction<{ organizationId: string }>,
) => {
state.organizationId = payload.action.organizationId;
},
[t.SET_TENANT_ID]: (state, payload: PayloadAction<{ tenantId: string }>) => {
state.tenantId = payload.action.tenantId;
},
[t.SET_USER_ID]: (state, payload: PayloadAction<{ userId: string }>) => {
state.userId = payload.action.userId;
},
[t.RESET]: (state) => {

View File

@@ -7,5 +7,10 @@ export default {
LOGOUT: 'LOGOUT',
LOGIN_CLEAR_ERRORS: 'LOGIN_CLEAR_ERRORS',
RESET: 'RESET',
SET_EMAIL_VERIFIED: 'SET_EMAIL_VERIFIED'
SET_EMAIL_VERIFIED: 'SET_EMAIL_VERIFIED',
SET_AUTH_TOKEN: 'SET_AUTH_TOKEN',
SET_ORGANIZATIOIN_ID: 'SET_ORGANIZATIOIN_ID',
SET_TENANT_ID: 'SET_TENANT_ID',
SET_USER_ID: 'SET_USER_ID',
SET_LOCALE: 'SET_LOCALE',
};