#94 brian_auth_fix

Birleştirildi
maeda dev 2 yıl önce içindeki brian_auth_fix işlemelerini 2 ile birleştirdi

+ 2
- 2
backend/lib/routes/user/validate-session.js Dosyayı Görüntüle

59
                         `Could not validate session token: ${userSession.sessionToken}`,
59
                         `Could not validate session token: ${userSession.sessionToken}`,
60
                     )
60
                     )
61
                 }
61
                 }
62
-                if (userSession?.email)
62
+                if (!userSession?.email)
63
                     throw new Error(
63
                     throw new Error(
64
                         `Could not validate token based on payload: ${request.payload}`,
64
                         `Could not validate token based on payload: ${request.payload}`,
65
                     )
65
                     )
85
                 return {
85
                 return {
86
                     ok: false,
86
                     ok: false,
87
                     handler: pluginConfig.handlerType,
87
                     handler: pluginConfig.handlerType,
88
-                    data: { error: err },
88
+                    data: { error: err.message },
89
                 }
89
                 }
90
             }
90
             }
91
         },
91
         },

+ 3
- 5
backend/lib/routes/user/verify-session.js Dosyayı Görüntüle

53
                 }
53
                 }
54
                 // NOTE: When user responds to email,
54
                 // NOTE: When user responds to email,
55
                 // boolean value is set to true, allowing user back into the survey
55
                 // boolean value is set to true, allowing user back into the survey
56
-                userService.activeSessions[
57
-                    hashToMatch
58
-                ].emailWasRespondedTo = true
56
+                userService.activeSessions[hashToMatch].emailWasRespondedTo =
57
+                    true
59
                 return {
58
                 return {
60
                     ok: true,
59
                     ok: true,
61
                     handler: pluginConfig.handlerType,
60
                     handler: pluginConfig.handlerType,
64
                     },
63
                     },
65
                 }
64
                 }
66
             } catch (err) {
65
             } catch (err) {
67
-                console.log('err :=>', err)
68
                 return {
66
                 return {
69
                     ok: false,
67
                     ok: false,
70
                     handler: pluginConfig.handlerType,
68
                     handler: pluginConfig.handlerType,
71
                     data: {
69
                     data: {
72
-                        error: err,
70
+                        error: err.message,
73
                     },
71
                     },
74
                 }
72
                 }
75
             }
73
             }

+ 1
- 3
frontend/src/router/guards.js Dosyayı Görüntüle

4
 const DEV_MODE = import.meta.env.VITE_DEV == 'true'
4
 const DEV_MODE = import.meta.env.VITE_DEV == 'true'
5
 
5
 
6
 async function log(to) {
6
 async function log(to) {
7
-    // if (DEV_MODE) {
8
     if (!currentProfile.isLoggedIn || !currentProfile.isComplete) {
7
     if (!currentProfile.isLoggedIn || !currentProfile.isComplete) {
9
         console.info(
8
         console.info(
10
             `[Guard Status debug]: Profile: ${currentProfile.id.value} | Login: ${currentProfile.isLoggedIn} | Complete: ${currentProfile.isComplete}`,
9
             `[Guard Status debug]: Profile: ${currentProfile.id.value} | Login: ${currentProfile.isLoggedIn} | Complete: ${currentProfile.isComplete}`,
11
         )
10
         )
12
     }
11
     }
13
     console.info('[Guard Status debug]: being routed to:', to.fullPath)
12
     console.info('[Guard Status debug]: being routed to:', to.fullPath)
14
-    // }
15
 }
13
 }
16
 
14
 
17
 const loginIfToken = async () => {
15
 const loginIfToken = async () => {
35
     if (DEV_MODE) {
33
     if (DEV_MODE) {
36
         nextCb()
34
         nextCb()
37
     } else if (
35
     } else if (
38
-        destination.meta.requiresCompleteProfile &&
36
+        destination.meta.requiresAuth &&
39
         !currentProfile.isLoggedIn &&
37
         !currentProfile.isLoggedIn &&
40
         !currentProfile.isComplete
38
         !currentProfile.isComplete
41
     ) {
39
     ) {

+ 1
- 1
frontend/src/router/index.js Dosyayı Görüntüle

64
         path: `/onboarding/`,
64
         path: `/onboarding/`,
65
         component: OnboardingView,
65
         component: OnboardingView,
66
         name: `OnboardingView`,
66
         name: `OnboardingView`,
67
-        meta: { requiresAuth: true, requiresCompleteProfile: false },
67
+        meta: { requiresAuth: false, requiresCompleteProfile: false },
68
     },
68
     },
69
     // We must be able to get to this route BEFORE login to activate the session
69
     // We must be able to get to this route BEFORE login to activate the session
70
     {
70
     {

+ 2
- 2
frontend/src/services/auth.service.js Dosyayı Görüntüle

9
         let verification
9
         let verification
10
         try {
10
         try {
11
             verification = await db.get(`/user/verify/${hashedToken}`)
11
             verification = await db.get(`/user/verify/${hashedToken}`)
12
+            if (verification.error) throw new Error(verification.error)
12
         } catch (error) {
13
         } catch (error) {
13
             console.error(error)
14
             console.error(error)
14
         }
15
         }
15
-        console.log('verifiedSession :>> ', verification)
16
         return verification
16
         return verification
17
     }
17
     }
18
     async createToken(req) {
18
     async createToken(req) {
24
         let validation
24
         let validation
25
         try {
25
         try {
26
             validation = await db.post('/user/validate-session', hash, true)
26
             validation = await db.post('/user/validate-session', hash, true)
27
+            if (validation.error) throw new Error(validation.error)
27
         } catch (error) {
28
         } catch (error) {
28
             console.error(`Invalid session: ${error}`)
29
             console.error(`Invalid session: ${error}`)
29
         }
30
         }
30
-        console.log('valid Session :>> ', validation)
31
         return validation
31
         return validation
32
     }
32
     }
33
     async authenticateLoginCredentials(credentials) {
33
     async authenticateLoginCredentials(credentials) {

+ 2
- 3
frontend/src/views/VerifyView.vue Dosyayı Görüntüle

5
 </template>
5
 </template>
6
 
6
 
7
 <script>
7
 <script>
8
-import { currentProfile, authenticator } from '../services'
8
+import { authenticator } from '../services'
9
 let hash = null
9
 let hash = null
10
 export default {
10
 export default {
11
     name: 'VerifyView',
11
     name: 'VerifyView',
18
             sessionData = await authenticator.verifySession(hash)
18
             sessionData = await authenticator.verifySession(hash)
19
             if (!sessionData.hashesMatch)
19
             if (!sessionData.hashesMatch)
20
                 throw new Error('Hash is not in activeSessions!')
20
                 throw new Error('Hash is not in activeSessions!')
21
-            
22
             /** Check if session was confirmed and is now valid in guard*/
21
             /** Check if session was confirmed and is now valid in guard*/
23
             this.$router.push('/')
22
             this.$router.push('/')
24
         } catch (err) {
23
         } catch (err) {
25
             console.error(err)
24
             console.error(err)
26
         }
25
         }
27
-    }
26
+    },
28
 }
27
 }
29
 </script>
28
 </script>
30
 
29
 

Loading…
İptal
Kaydet