|
|
@@ -13,7 +13,6 @@ export default {
|
|
13
|
13
|
answers: {},
|
|
14
|
14
|
hash: undefined,
|
|
15
|
15
|
sessionToken: undefined,
|
|
16
|
|
- accessToken: undefined,
|
|
17
|
16
|
}),
|
|
18
|
17
|
async created() {
|
|
19
|
18
|
this.authenticator = new Authenticator()
|
|
|
@@ -23,11 +22,7 @@ export default {
|
|
23
|
22
|
this.isHashInUrl(this.hash)
|
|
24
|
23
|
this.doesEmailMatch(this.hash)
|
|
25
|
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
|
26
|
} catch (err) {
|
|
32
|
27
|
console.error(err)
|
|
33
|
28
|
}
|
|
|
@@ -47,10 +42,11 @@ export default {
|
|
47
|
42
|
: undefined
|
|
48
|
43
|
},
|
|
49
|
44
|
async getAccessToken(payload) {
|
|
50
|
|
- return await this.authenticator.getJwt({
|
|
|
45
|
+ const accessToken = await this.authenticator.getJwt({
|
|
51
|
46
|
payload,
|
|
52
|
47
|
expires: 60 * 3,
|
|
53
|
48
|
})
|
|
|
49
|
+ document.cookie = `siimee_access=${accessToken}; max-age=600; path=/; secure`
|
|
54
|
50
|
},
|
|
55
|
51
|
isHashInUrl(hash) {
|
|
56
|
52
|
if (!hash) throw new Error('URL contains no hash!')
|
|
|
@@ -72,7 +68,7 @@ export default {
|
|
72
|
68
|
throw new Error(sessionTokenIsValid.error)
|
|
73
|
69
|
} else {
|
|
74
|
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
|
},
|