File tree Expand file tree Collapse file tree 5 files changed +15
-9
lines changed Expand file tree Collapse file tree 5 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 1
1
<script lang="ts" setup>
2
- const auth = useAuthStore ();
3
-
4
- if (auth .logged ) {
5
- await auth .fetchUser ();
6
- }
7
2
</script >
8
3
9
4
<template >
Original file line number Diff line number Diff line change 1
1
export default defineNuxtRouteMiddleware ( ( to , from ) => {
2
2
const auth = useAuthStore ( )
3
3
4
- if ( auth . logged && ! auth . hasRole ( 'admin' ) ) {
4
+ if ( ! auth . logged || ! auth . hasRole ( 'admin' ) ) {
5
5
const toast = useToast ( )
6
6
7
7
toast . add ( {
Original file line number Diff line number Diff line change 1
1
export default defineNuxtRouteMiddleware ( ( to , from ) => {
2
2
const auth = useAuthStore ( )
3
3
4
- if ( auth . logged && ! auth . hasRole ( 'user' ) ) {
4
+ if ( ! auth . logged || ! auth . hasRole ( 'user' ) ) {
5
5
const toast = useToast ( )
6
6
7
7
toast . add ( {
Original file line number Diff line number Diff line change 1
- export default defineNuxtRouteMiddleware ( ( to , from ) => {
1
+ import authMiddleware from "./auth" ;
2
+
3
+ export default defineNuxtRouteMiddleware ( async ( to , from ) => {
4
+ await authMiddleware ( to , from ) ;
5
+
2
6
const auth = useAuthStore ( ) ;
3
7
4
- if ( auth . logged && auth . user . must_verify_email ) {
8
+ if ( auth . user . must_verify_email ) {
5
9
const toast = useToast ( ) ;
6
10
7
11
toast . add ( {
Original file line number Diff line number Diff line change
1
+ export default defineNuxtPlugin ( async ( nuxtApp ) => {
2
+ const auth = useAuthStore ( ) ;
3
+
4
+ if ( auth . logged ) {
5
+ await auth . fetchUser ( ) ;
6
+ }
7
+ } )
You can’t perform that action at this time.
0 commit comments