Client - allow user to change email
This commit is contained in:
@ -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 {
|
||||
|
@ -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',
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user