|
|
@@ -65,39 +65,32 @@ export default {
|
|
65
|
65
|
async created() {
|
|
66
|
66
|
this.survey = await surveyFactory.createSurvey()
|
|
67
|
67
|
this.authenticator = new Authenticator()
|
|
68
|
|
- if (document.cookie.length) {
|
|
69
|
|
- const sessionToken = this.grabCookie('siimee_session_onboarding')
|
|
70
|
|
- if (sessionToken) {
|
|
71
|
|
- const sessionData = await this.authenticator.validateJwt(
|
|
72
|
|
- sessionToken,
|
|
73
|
|
- )
|
|
74
|
|
- // NOTE: Left off here, INCOMPLETE, no ACCESS TOKEN yet, crazy amount of logic here...
|
|
75
|
|
- if (sessionData.isValid) {
|
|
76
|
|
- const userEmail = sessionData.payload.email
|
|
77
|
|
- const emailIsInCache =
|
|
78
|
|
- await this.authenticator.checkEmailCache(userEmail)
|
|
79
|
|
- if (emailIsInCache) {
|
|
80
|
|
- const user = await fetchUserByEmail(userEmail)
|
|
81
|
|
- const userId = user.user_id
|
|
82
|
|
- const profilesFromUserId = await fetchProfilesByUserId(
|
|
83
|
|
- userId,
|
|
84
|
|
- )
|
|
85
|
|
- let profileId
|
|
86
|
|
- if (profilesFromUserId.length === 1) {
|
|
87
|
|
- profileId = profilesFromUserId[0].profile_id
|
|
88
|
|
- this.currentProfileId = profileId
|
|
89
|
|
- }
|
|
90
|
|
- const profile = await fetchProfileByProfileId(profileId)
|
|
91
|
|
- profile.responses.forEach(response => {
|
|
92
|
|
- this.responses.push({
|
|
93
|
|
- response_key_id: response.response_key_id,
|
|
94
|
|
- val: response.val,
|
|
95
|
|
- })
|
|
96
|
|
- })
|
|
97
|
|
- this.currentStep = this.responses.length + 3
|
|
98
|
|
- this.goToStep(this.currentStep)
|
|
99
|
|
- }
|
|
|
68
|
+ const sessionToken = this.grabCookie('siimee_session_onboarding')
|
|
|
69
|
+ const sessionData = await this.authenticator.validateJwt(sessionToken)
|
|
|
70
|
+ // 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,
|
|
|
75
|
+ )
|
|
|
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
|
|
100
|
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)
|
|
101
|
94
|
}
|
|
102
|
95
|
}
|
|
103
|
96
|
},
|