diff --git a/front/src/components/auth/LoginForm.vue b/front/src/components/auth/LoginForm.vue index 0c90ab958..41be7710b 100644 --- a/front/src/components/auth/LoginForm.vue +++ b/front/src/components/auth/LoginForm.vue @@ -3,6 +3,7 @@ import type { BackendError } from '~/types' import type { RouteLocationRaw } from 'vue-router' import { ref, reactive, computed, onMounted, nextTick } from 'vue' +import { useRouter } from 'vue-router' import { useI18n } from 'vue-i18n' import { useStore } from '~/store' @@ -23,6 +24,7 @@ const props = withDefaults(defineProps(), { const domain = location.hostname const { t } = useI18n() const store = useStore() +const router = useRouter() const credentials = reactive({ username: '', @@ -47,6 +49,7 @@ const submit = async () => { try { if (domain === store.getters['instance/domain']) { await store.dispatch('auth/login', { credentials }) + await router.push(props.next) } else { await store.dispatch('auth/oauthLogin', props.next) } diff --git a/front/src/router/guards.ts b/front/src/router/guards.ts index cdad7b525..914291a65 100644 --- a/front/src/router/guards.ts +++ b/front/src/router/guards.ts @@ -2,7 +2,6 @@ import type { NavigationGuardNext, RouteLocationNamedRaw, RouteLocationNormalized } from 'vue-router' import type { Permission } from '~/store/auth' -import router from '~/router' import store from '~/store' export const hasPermissions = (permission: Permission) => (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => { @@ -16,7 +15,8 @@ export const hasPermissions = (permission: Permission) => (to: RouteLocationNorm export const requireLoggedIn = (fallbackLocation?: RouteLocationNamedRaw) => (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => { if (store.state.auth.authenticated) return next() - return next(fallbackLocation ?? { name: 'login', query: { next: router.currentRoute.value.fullPath } }) + console.log('!', to) + return next(fallbackLocation ?? { name: 'login', query: { next: to.fullPath } }) } export const requireLoggedOut = (fallbackLocation: RouteLocationNamedRaw) => (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => {