-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
less cls in main page and fixed auth refresh
- Loading branch information
Showing
6 changed files
with
30 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
<NuxtPage /> | ||
</NuxtLayout> | ||
</VApp> | ||
</template> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
import { usePocketbase } from '#imports' | ||
|
||
export default defineNuxtRouteMiddleware(async (to, from, next) => { | ||
export default defineNuxtRouteMiddleware(async (to, from) => { | ||
// Ensure the middleware runs only on the client side | ||
if (process.client) { | ||
const authRequired = to.meta.authRequired || true | ||
|
||
const pb = usePocketbase() | ||
|
||
// Retrieve the current session from Supabase | ||
// Retrieve the current session from Pocketbase | ||
const isValidSession = pb.authStore.isValid | ||
|
||
if (authRequired && to.path !== '/') { | ||
if (!isValidSession) { | ||
// If the session is not valid, redirect to the login page | ||
return navigateTo('/login') | ||
} | ||
if (to.name === 'Login' && isValidSession) { | ||
// Redirect to the dashboard if already logged in and trying to access the login page | ||
return navigateTo('/dashboard') | ||
} | ||
if (!isValidSession) { | ||
// If the session is not valid, redirect to the login page | ||
return navigateTo('/login') | ||
} | ||
|
||
if (to.name === 'Login' && isValidSession) { | ||
// Redirect to the dashboard if already logged in and trying to access the login page | ||
return navigateTo('/dashboard') | ||
} | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters