ソースを参照

:recycle: tweak login cookie | don't pass session key string around just set default arg

brian_lifecycle_docs
j 2年前
コミット
917746c00c

+ 1
- 3
frontend/src/router/guards.js ファイルの表示

15
 }
15
 }
16
 
16
 
17
 const loginIfToken = async () => {
17
 const loginIfToken = async () => {
18
-    const sessionData = await authenticator.verifySessionCookie(
19
-        'siimee_session',
20
-    )
18
+    const sessionData = await authenticator.verifySessionCookie()
21
     if (
19
     if (
22
         sessionData?.profileId &&
20
         sessionData?.profileId &&
23
         sessionData?.sessionToken &&
21
         sessionData?.sessionToken &&

+ 6
- 10
frontend/src/services/auth.service.js ファイルの表示

25
             prev[name] = value.join('=')
25
             prev[name] = value.join('=')
26
             return prev
26
             return prev
27
         }, {})
27
         }, {})
28
-        const cookieVal =
29
-            cookieKey in cookies ? cookies[`${cookieKey}`] : undefined
30
-        return cookieVal
28
+        return cookies[cookieKey]
31
     }
29
     }
32
-    async verifySessionCookie(sessionCookie) {
33
-        const hashedAccessToken = this.grabStoredCookie(sessionCookie)
30
+    async verifySessionCookie(sessionCookieKey = 'siimee_session') {
31
+        const hashedAccessToken = this.grabStoredCookie(sessionCookieKey)
34
         if (!hashedAccessToken)
32
         if (!hashedAccessToken)
35
             return console.warn('WARNING :=> accessToken is not defined')
33
             return console.warn('WARNING :=> accessToken is not defined')
36
         const validatedToken = await this.validateSession(hashedAccessToken)
34
         const validatedToken = await this.validateSession(hashedAccessToken)
37
-        if (validatedToken.error) {
38
-            console.error('ERROR :=>', validatedToken.error)
39
-        } else {
40
-            return validatedToken
41
-        }
35
+        if (validatedToken.error)
36
+            return console.error('ERROR :=>', validatedToken.error)
37
+        return validatedToken
42
     }
38
     }
43
 }
39
 }
44
 const authenticator = new Authenticator()
40
 const authenticator = new Authenticator()

+ 1
- 1
frontend/src/views/LoginView.vue ファイルの表示

55
             if (sessionInfo.emailSentSuccessfully) {
55
             if (sessionInfo.emailSentSuccessfully) {
56
                 this.emailSentSuccessfully = true
56
                 this.emailSentSuccessfully = true
57
             }
57
             }
58
-            document.cookie = `siimee_session=${sessionInfo.hashedSessionToken}; max-age=600; path=/`
58
+            document.cookie = `siimee_session=${sessionInfo.hashedSessionToken}; max-age=600; path=/; SameSite=Lax`
59
         },
59
         },
60
     },
60
     },
61
 }
61
 }

+ 2
- 4
frontend/src/views/OnboardingView.vue ファイルの表示

60
         // TODO: Troubleshoot bug where not all responses are returned at SurveyCompleteView
60
         // TODO: Troubleshoot bug where not all responses are returned at SurveyCompleteView
61
         this.survey = await surveyFactory.createSurvey()
61
         this.survey = await surveyFactory.createSurvey()
62
         try {
62
         try {
63
-            const sessionData = await authenticator.verifySessionCookie(
64
-                'siimee_session',
65
-            )
63
+            const sessionData = await authenticator.verifySessionCookie()
66
             if (sessionData) {
64
             if (sessionData) {
67
                 this.responses = this.formatResponses(
65
                 this.responses = this.formatResponses(
68
                     currentProfile._profile.responses,
66
                     currentProfile._profile.responses,
115
                 )
113
                 )
116
                 currentProfile._profile.responses = this.responses
114
                 currentProfile._profile.responses = this.responses
117
                 try {
115
                 try {
118
-                    await authenticator.verifySessionCookie('siimee_session')
116
+                    await authenticator.verifySessionCookie()
119
                 } catch (err) {
117
                 } catch (err) {
120
                     this.currentStep = 0
118
                     this.currentStep = 0
121
                     this.goToStep(this.currentStep)
119
                     this.goToStep(this.currentStep)

+ 1
- 2
frontend/src/views/VerifyView.vue ファイルの表示

14
         try {
14
         try {
15
             this.isHashInUrl(hash)
15
             this.isHashInUrl(hash)
16
             await this.verifyActiveSession(hash)
16
             await this.verifyActiveSession(hash)
17
-            const sessionData =
18
-                await authenticator.verifySessionCookie('siimee_session')
17
+            const sessionData = await authenticator.verifySessionCookie()
19
             currentProfile.login(
18
             currentProfile.login(
20
                 sessionData.profileId,
19
                 sessionData.profileId,
21
                 this.$waveui.notify,
20
                 this.$waveui.notify,

読み込み中…
キャンセル
保存