Pārlūkot izejas kodu

:recycle: guard conditional change

neo
toj 2 gadus atpakaļ
vecāks
revīzija
ca61bd4f28
1 mainītis faili ar 10 papildinājumiem un 8 dzēšanām
  1. 10
    8
      frontend/src/router/guards.js

+ 10
- 8
frontend/src/router/guards.js Parādīt failu

18
     const sessionData = await authenticator.checkSessionValid()
18
     const sessionData = await authenticator.checkSessionValid()
19
     if (
19
     if (
20
         sessionData?.profileId &&
20
         sessionData?.profileId &&
21
-        sessionData?.sessionToken
21
+        sessionData?.sessionToken &&
22
+        !currentProfile.isLoggedIn
22
     ) {
23
     ) {
23
         await currentProfile.login(
24
         await currentProfile.login(
24
             sessionData.profileId,
25
             sessionData.profileId,
29
 }
30
 }
30
 
31
 
31
 const checkLoginStatus = async (destination, nextCb) => {
32
 const checkLoginStatus = async (destination, nextCb) => {
32
-    if(!currentProfile.isLoggedIn) {
33
-        await loginIfToken()
34
-    }
33
+    await loginIfToken()
35
     log(destination)
34
     log(destination)
36
     if (DEV_MODE) {
35
     if (DEV_MODE) {
37
         nextCb()
36
         nextCb()
38
     } else if (
37
     } else if (
39
-        !currentProfile.isLoggedIn
38
+        destination.meta.requiresCompleteProfile &&
39
+        !currentProfile.isLoggedIn &&
40
+        !currentProfile.isComplete
40
     ) {
41
     ) {
41
-        nextCb('/login')
42
+        nextCb('/onboarding')
42
     } else if (
43
     } else if (
43
         destination.meta.requiresCompleteProfile &&
44
         destination.meta.requiresCompleteProfile &&
44
-        destination.meta.requiresAuth
45
+        destination.meta.requiresAuth &&
46
+        !currentProfile.isLoggedIn
45
     ) {
47
     ) {
46
-        nextCb('/onboarding')
48
+        nextCb('/login')
47
     } else {
49
     } else {
48
         nextCb()
50
         nextCb()
49
     }
51
     }

Notiek ielāde…
Atcelt
Saglabāt