mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Fixed wrong redirection
This commit is contained in:
@@ -3,9 +3,4 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useAuthStore } from '@/stores'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
|
||||
authStore.initialize()
|
||||
</script>
|
||||
|
||||
@@ -294,11 +294,14 @@ const router = createRouter({
|
||||
routes,
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
if (to.meta.requiresAuth !== undefined) {
|
||||
const previousPage = window.location.href
|
||||
sessionStorage.setItem('previousPage', previousPage)
|
||||
const authStore = useAuthStore()
|
||||
if (!authStore.authUser) {
|
||||
await authStore.initialize()
|
||||
}
|
||||
authStore.validateAccess()
|
||||
if (to.meta.allowedRoles !== undefined) {
|
||||
if (to.meta.allowedRoles.indexOf(authStore.authUser.role) === -1) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import accountApi from '@/api/account'
|
||||
import accountsApi from '@/api/accounts'
|
||||
|
||||
export const useAuthStore = defineStore('auth', () => {
|
||||
const authUser = ref({})
|
||||
const authUser = ref(null)
|
||||
const isAuthenticated = ref(false)
|
||||
const manager = new UserManager({
|
||||
authority: 'http://localhost:8000/api/o',
|
||||
|
||||
Reference in New Issue
Block a user