|
|
@@ -60,6 +60,10 @@ export default {
|
|
60
|
60
|
currentProfileId: null,
|
|
61
|
61
|
survey: null,
|
|
62
|
62
|
invalidResponse: false,
|
|
|
63
|
+ userEmail: null,
|
|
|
64
|
+ emailIsInCache: false,
|
|
|
65
|
+ sessionToken: null, // need this?
|
|
|
66
|
+ accessToken: null,
|
|
63
|
67
|
authenticator: {},
|
|
64
|
68
|
}),
|
|
65
|
69
|
async created() {
|
|
|
@@ -67,31 +71,33 @@ export default {
|
|
67
|
71
|
this.authenticator = new Authenticator()
|
|
68
|
72
|
const sessionToken = this.grabCookie('siimee_session_onboarding')
|
|
69
|
73
|
const sessionData = await this.authenticator.validateJwt(sessionToken)
|
|
|
74
|
+
|
|
|
75
|
+ const accessToken = this.grabCookie('siimee_access_onboarding')
|
|
70
|
76
|
// NOTE: Left off here, INCOMPLETE, no ACCESS TOKEN yet, crazy amount of logic here...
|
|
71
|
|
- if (sessionData.isValid) {
|
|
72
|
|
- const userEmail = sessionData.payload.email
|
|
73
|
|
- const emailIsInCache = await this.authenticator.checkEmailCache(
|
|
74
|
|
- userEmail,
|
|
|
77
|
+ if (sessionData.isValid && !accessToken) {
|
|
|
78
|
+ this.userEmail = sessionData.payload.email
|
|
|
79
|
+ this.emailIsInCache = await this.authenticator.checkEmailCache(
|
|
|
80
|
+ this.userEmail,
|
|
75
|
81
|
)
|
|
76
|
|
- if (emailIsInCache) {
|
|
77
|
|
- const user = await fetchUserByEmail(userEmail)
|
|
78
|
|
- const userId = user.user_id
|
|
79
|
|
- const profilesFromUserId = await fetchProfilesByUserId(userId)
|
|
80
|
|
- let profileId
|
|
81
|
|
- if (profilesFromUserId.length === 1) {
|
|
82
|
|
- profileId = profilesFromUserId[0].profile_id
|
|
83
|
|
- this.currentProfileId = profileId
|
|
84
|
|
- }
|
|
85
|
|
- const profile = await fetchProfileByProfileId(profileId)
|
|
86
|
|
- profile.responses.forEach(response => {
|
|
87
|
|
- this.responses.push({
|
|
88
|
|
- response_key_id: response.response_key_id,
|
|
89
|
|
- val: response.val,
|
|
90
|
|
- })
|
|
91
|
|
- })
|
|
92
|
|
- this.currentStep = this.responses.length + 3
|
|
93
|
|
- this.goToStep(this.currentStep)
|
|
|
82
|
+ }
|
|
|
83
|
+ if (this.emailIsInCache) {
|
|
|
84
|
+ const user = await fetchUserByEmail(this.userEmail)
|
|
|
85
|
+ const userId = user.user_id
|
|
|
86
|
+ const profilesFromUserId = await fetchProfilesByUserId(userId)
|
|
|
87
|
+ let profileId
|
|
|
88
|
+ if (profilesFromUserId.length === 1) {
|
|
|
89
|
+ profileId = profilesFromUserId[0].profile_id
|
|
|
90
|
+ this.currentProfileId = profileId
|
|
94
|
91
|
}
|
|
|
92
|
+ const profile = await fetchProfileByProfileId(profileId)
|
|
|
93
|
+ profile.responses.forEach(response => {
|
|
|
94
|
+ this.responses.push({
|
|
|
95
|
+ response_key_id: response.response_key_id,
|
|
|
96
|
+ val: response.val,
|
|
|
97
|
+ })
|
|
|
98
|
+ })
|
|
|
99
|
+ this.currentStep = this.responses.length + 3
|
|
|
100
|
+ this.goToStep(this.currentStep)
|
|
95
|
101
|
}
|
|
96
|
102
|
},
|
|
97
|
103
|
methods: {
|