Client - allow user to change email

This commit is contained in:
Sam
2022-03-12 08:59:22 +01:00
parent 42dfeee283
commit ae0b9c36b2
15 changed files with 247 additions and 49 deletions

View File

@ -22,6 +22,7 @@ import {
ILoginOrRegisterData,
IUserAccountPayload,
IUserDeletionPayload,
IUserEmailUpdatePayload,
IUserPasswordPayload,
IUserPasswordResetPayload,
IUserPayload,
@ -62,6 +63,33 @@ export const actions: ActionTree<IAuthUserState, IRootState> &
context.dispatch(AUTH_USER_STORE.ACTIONS.GET_USER_PROFILE)
}
},
[AUTH_USER_STORE.ACTIONS.CONFIRM_EMAIL](
context: ActionContext<IAuthUserState, IRootState>,
payload: IUserEmailUpdatePayload
): void {
context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
context.commit(AUTH_USER_STORE.MUTATIONS.UPDATE_IS_SUCCESS, false)
api
.post('/auth/email/update', { token: payload.token })
.then((res) => {
if (res.data.status === 'success') {
context.commit(AUTH_USER_STORE.MUTATIONS.UPDATE_IS_SUCCESS, true)
if (payload.refreshUser) {
context
.dispatch(AUTH_USER_STORE.ACTIONS.GET_USER_PROFILE)
.then(() => {
return router.push('/profile/edit/account')
})
}
router.push('/profile/edit/account')
} else {
handleError(context, null)
}
})
.catch((error) => {
handleError(context, error)
})
},
[AUTH_USER_STORE.ACTIONS.GET_USER_PROFILE](
context: ActionContext<IAuthUserState, IRootState>
): void {

View File

@ -1,5 +1,6 @@
export enum AuthUserActions {
CHECK_AUTH_USER = 'CHECK_AUTH_USER',
CONFIRM_EMAIL = 'CONFIRM_EMAIL',
DELETE_ACCOUNT = 'DELETE_ACCOUNT',
DELETE_PICTURE = 'DELETE_PICTURE',
GET_USER_PROFILE = 'GET_USER_PROFILE',

View File

@ -18,6 +18,7 @@ import {
IUserPreferencesPayload,
IUserSportPreferencesPayload,
IUserAccountPayload,
IUserEmailUpdatePayload,
} from '@/types/user'
export interface IAuthUserState {
@ -32,6 +33,11 @@ export interface IAuthUserActions {
context: ActionContext<IAuthUserState, IRootState>
): void
[AUTH_USER_STORE.ACTIONS.CONFIRM_EMAIL](
context: ActionContext<IAuthUserState, IRootState>,
payload: IUserEmailUpdatePayload
): void
[AUTH_USER_STORE.ACTIONS.GET_USER_PROFILE](
context: ActionContext<IAuthUserState, IRootState>
): void