mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-21 13:23:14 +01:00
Add redirect functionality after login (#76)
Gone is the frustration of scanning a qr code to only be sent to the homepage
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
export default defineNuxtRouteMiddleware(async () => {
|
||||
const ctx = useAuthContext();
|
||||
const api = useUserApi();
|
||||
const redirectTo = useState("authRedirect");
|
||||
|
||||
if (!ctx.isAuthorized()) {
|
||||
if (window.location.pathname !== "/") {
|
||||
console.debug("[middleware/auth] isAuthorized returned false, redirecting to /");
|
||||
redirectTo.value = window.location.pathname;
|
||||
return navigateTo("/");
|
||||
}
|
||||
}
|
||||
@@ -15,6 +17,7 @@ export default defineNuxtRouteMiddleware(async () => {
|
||||
if (error) {
|
||||
if (window.location.pathname !== "/") {
|
||||
console.debug("[middleware/user] user is null and fetch failed, redirecting to /");
|
||||
redirectTo.value = window.location.pathname;
|
||||
return navigateTo("/");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user