Client - redirect after login if redirection exists

This commit is contained in:
Sam
2021-11-03 09:41:27 +01:00
parent 987503ca96
commit fece99921b
19 changed files with 34 additions and 26 deletions

View File

@ -156,6 +156,7 @@
store.dispatch(USER_STORE.ACTIONS.LOGIN_OR_REGISTER, {
actionType,
formData,
redirectUrl: route.query.from,
})
}
}

View File

@ -97,7 +97,11 @@ export const actions: ActionTree<IUserState, IRootState> & IUserActions = {
context.commit(USER_STORE.MUTATIONS.UPDATE_AUTH_TOKEN, token)
context
.dispatch(USER_STORE.ACTIONS.GET_USER_PROFILE)
.then(() => router.push('/'))
.then(() =>
router.push(
typeof data.redirectUrl === 'string' ? data.redirectUrl : '/'
)
)
} else {
handleError(context, null)
}

View File

@ -1,3 +1,5 @@
import { LocationQueryValue } from 'vue-router'
import { IRecord } from '@/types/workouts'
export interface IUserProfile {
@ -71,4 +73,5 @@ export interface ILoginRegisterFormData {
export interface ILoginOrRegisterData {
actionType: string
formData: ILoginRegisterFormData
redirectUrl?: string | null | LocationQueryValue[]
}