Skip to content

Commit

Permalink
Auth Guard code moved to sprinkle-account
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Jul 26, 2024
1 parent 35f477f commit 452e6c9
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions src/views/PageLogin.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
<script setup lang="ts">
import { watch } from 'vue'
import { useRouter } from 'vue-router'
import { useAuthStore } from '@userfrosting/sprinkle-account/stores'
import FormLogin from '../components/Content/FormLogin.vue'
// Stores
const auth = useAuthStore()
const router = useRouter()
// Watch for redirect
// TODO : Replace route guard with initial state check
// TODO : Should be moved to a composable or auth store, as this will be useful in other places,
// TODO : Should also use query redirect (to redirect where we were before login)
// @see : https://vue-auth3.js.org/guide/auth-meta.html#advanced-redirects
watch(
() => auth.isAuthenticated,
(isAuthenticated) => {
if (isAuthenticated === true) {
let redirectTo = router.currentRoute.value.meta.redirectAfterLogin ?? '/'
router.push(redirectTo)
}
}
)
</script>

<template>
Expand Down

0 comments on commit 452e6c9

Please sign in to comment.