This repository was archived by the owner on Jun 12, 2024. It is now read-only.
File tree 2 files changed +10
-6
lines changed
2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ class AuthContext implements IAuthContext {
45
45
private _attachmentToken : CookieRef < string | null > ;
46
46
47
47
get token ( ) {
48
- return this . _token . value === "true" ;
48
+ // @ts -ignore sometimes it's a boolean I guess?
49
+ return this . _token . value === "true" || this . _token . value === true ;
49
50
}
50
51
51
52
get attachmentToken ( ) {
@@ -66,11 +67,11 @@ class AuthContext implements IAuthContext {
66
67
}
67
68
68
69
isExpired ( ) {
69
- return this . token ;
70
+ return ! this . token ;
70
71
}
71
72
72
73
isAuthorized ( ) {
73
- return ! this . isExpired ( ) ;
74
+ return this . token ;
74
75
}
75
76
76
77
invalidateSession ( ) {
@@ -79,7 +80,6 @@ class AuthContext implements IAuthContext {
79
80
// Delete the cookies
80
81
this . _token . value = null ;
81
82
this . _attachmentToken . value = null ;
82
-
83
83
console . log ( "Session invalidated" ) ;
84
84
}
85
85
Original file line number Diff line number Diff line change @@ -3,14 +3,18 @@ export default defineNuxtRouteMiddleware(async () => {
3
3
const api = useUserApi ( ) ;
4
4
5
5
if ( ! ctx . isAuthorized ( ) ) {
6
- return navigateTo ( "/" ) ;
6
+ if ( window . location . pathname !== "/" ) {
7
+ return navigateTo ( "/" ) ;
8
+ }
7
9
}
8
10
9
11
if ( ! ctx . user ) {
10
12
console . log ( "Fetching user data" ) ;
11
13
const { data, error } = await api . user . self ( ) ;
12
14
if ( error ) {
13
- return navigateTo ( "/" ) ;
15
+ if ( window . location . pathname !== "/" ) {
16
+ return navigateTo ( "/" ) ;
17
+ }
14
18
}
15
19
16
20
ctx . user = data . item ;
You can’t perform that action at this time.
0 commit comments