Bladeren bron

:bug: Fixed bug with auth token

tags/0.0.3^2
tomit4 3 jaren geleden
bovenliggende
commit
fd8ca55f33
1 gewijzigde bestanden met toevoegingen van 4 en 8 verwijderingen
  1. 4
    8
      frontend/src/views/VerifyView.vue

+ 4
- 8
frontend/src/views/VerifyView.vue Bestand weergeven

13
         answers: {},
13
         answers: {},
14
         hash: undefined,
14
         hash: undefined,
15
         sessionToken: undefined,
15
         sessionToken: undefined,
16
-        accessToken: undefined,
17
     }),
16
     }),
18
     async created() {
17
     async created() {
19
         this.authenticator = new Authenticator()
18
         this.authenticator = new Authenticator()
23
             this.isHashInUrl(this.hash)
22
             this.isHashInUrl(this.hash)
24
             this.doesEmailMatch(this.hash)
23
             this.doesEmailMatch(this.hash)
25
             this.doesSessionTokenExist(this.sessionToken)
24
             this.doesSessionTokenExist(this.sessionToken)
26
-            const sessionTokenIsValid = this.isSessionTokenValid(
27
-                this.sessionToken,
28
-            )
29
-            if (sessionTokenIsValid)
30
-                document.cookie = `siimee_access=${this.accessToken}; max-age=600; path=/; secure`
25
+            this.isSessionTokenValid(this.sessionToken)
31
         } catch (err) {
26
         } catch (err) {
32
             console.error(err)
27
             console.error(err)
33
         }
28
         }
47
                 : undefined
42
                 : undefined
48
         },
43
         },
49
         async getAccessToken(payload) {
44
         async getAccessToken(payload) {
50
-            return await this.authenticator.getJwt({
45
+            const accessToken = await this.authenticator.getJwt({
51
                 payload,
46
                 payload,
52
                 expires: 60 * 3,
47
                 expires: 60 * 3,
53
             })
48
             })
49
+            document.cookie = `siimee_access=${accessToken}; max-age=600; path=/; secure`
54
         },
50
         },
55
         isHashInUrl(hash) {
51
         isHashInUrl(hash) {
56
             if (!hash) throw new Error('URL contains no hash!')
52
             if (!hash) throw new Error('URL contains no hash!')
72
                 throw new Error(sessionTokenIsValid.error)
68
                 throw new Error(sessionTokenIsValid.error)
73
             } else {
69
             } else {
74
                 // TODO: Does accessToken need sessionToken data?
70
                 // TODO: Does accessToken need sessionToken data?
75
-                this.accessToken = await this.getAccessToken(this.sessionToken)
71
+                await this.getAccessToken(...this.sessionToken)
76
             }
72
             }
77
         },
73
         },
78
     },
74
     },

Laden…
Annuleren
Opslaan