Skip to content

Commit

Permalink
after login redirect to path the user tried to visit
Browse files Browse the repository at this point in the history
  • Loading branch information
scammo committed Apr 21, 2024
1 parent 681dbb5 commit 5a3e557
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frontend/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ router.beforeEach(async (to, from, next) => {
setLogin(localStorageAuth.user, localStorageAuth.token)
}
const requiresAuth = to.matched.some((record) => record.meta.requiresAuth);
if (requiresAuth && !isLoggedIn()) next("/login");
if (requiresAuth && !isLoggedIn()) next(`/login?redirect=${to.fullPath}`);
//else if(!requiresAuth && currentUser) next("/orga");
else next();
});
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import InputText from "primevue/inputtext";
import Button from "primevue/button";
import Toast from 'primevue/toast';
import { ref } from "vue";
import { useRouter } from "vue-router";
import { useRouter, useRoute } from "vue-router";
import { client, setLogin } from "../lib/api";
import { useToast } from 'primevue/usetoast';
const toast = useToast();
const router = useRouter();
const route = useRoute();
const loading = ref(false);
const email = ref(import.meta.env.PROD ? "" : "[email protected]");
Expand All @@ -24,7 +25,7 @@ const onSubmit = async () => {
setLogin(response.data.user, response.data.authorization.token)
router.push('/orga')
router.push(route.query.redirect || '/orga')
} catch (error) {
console.error(error)
toast.add({ severity: 'error', summary: 'Login war nicht erfolgreich', life: 6000 });
Expand Down

0 comments on commit 5a3e557

Please sign in to comment.