|
|
@@ -18,7 +18,6 @@ main.view--onboarding
|
|
18
|
18
|
:surveyStepsCount='survey.steps.length'
|
|
19
|
19
|
@handle-submit='onSubmit'
|
|
20
|
20
|
@update-answers='updateAnswers'
|
|
21
|
|
- @set-pid='setPid'
|
|
22
|
21
|
v-if='step && currentStep == i'
|
|
23
|
22
|
)
|
|
24
|
23
|
.invalidResponseMessage(
|
|
|
@@ -31,7 +30,7 @@ main.view--onboarding
|
|
31
|
30
|
p(v-if='currentStep != 0') You have completed: {{ currentStep }} / {{ survey.steps.length }} survey steps
|
|
32
|
31
|
|
|
33
|
32
|
article(v-else)
|
|
34
|
|
- SurveyCompleteView(:answers='answered' :surveySteps='survey.steps')
|
|
|
33
|
+ SurveyCompleteView(:answers='answered' :surveySteps='survey.steps' :currentProfileId='currentProfileId')
|
|
35
|
34
|
</template>
|
|
36
|
35
|
|
|
37
|
36
|
<script>
|
|
|
@@ -57,15 +56,14 @@ export default {
|
|
57
|
56
|
survey: null,
|
|
58
|
57
|
currentProfileId: null,
|
|
59
|
58
|
invalidResponse: false,
|
|
60
|
|
- // TODO: CURRENTLY WORKING ON**
|
|
61
|
59
|
authenticator: {},
|
|
62
|
60
|
sessionToken: '',
|
|
63
|
61
|
accessToken: '',
|
|
64
|
62
|
}),
|
|
65
|
63
|
computed: {
|
|
66
|
|
- // NOTE: perhaps start this off as returning nothing
|
|
67
|
|
- // and then add currentProfile in created()?
|
|
68
|
|
- profile: () => currentProfile,
|
|
|
64
|
+ cP() {
|
|
|
65
|
+ return currentProfile ? currentProfile : null
|
|
|
66
|
+ },
|
|
69
|
67
|
},
|
|
70
|
68
|
async created() {
|
|
71
|
69
|
this.survey = await surveyFactory.createSurvey()
|
|
|
@@ -74,25 +72,34 @@ export default {
|
|
74
|
72
|
if (document.cookie.length) {
|
|
75
|
73
|
// TODO: Remove this this.answered section when:
|
|
76
|
74
|
// SurveyCompleteView calls all responses from db
|
|
77
|
|
- // BUG: NEEDS BROWSER REFRESH TO BE HIT
|
|
78
|
|
- const siimeeAnswers = JSON.parse(
|
|
79
|
|
- this.grabCookie(document.cookie, 'siimee_answered'),
|
|
80
|
|
- )
|
|
81
|
|
- this.sessionToken = this.grabCookie(
|
|
|
75
|
+ // BUG: NEEDS BROWSER REFRESH TO SEE UPDATED COOKIES
|
|
|
76
|
+ const siimeeAnswered = this.grabCookie(
|
|
82
|
77
|
document.cookie,
|
|
83
|
|
- 'siimee_session',
|
|
84
|
|
- )
|
|
85
|
|
- const sessionTokenIsValid = await this.authenticator.validateJwt(
|
|
86
|
|
- this.sessionToken,
|
|
|
78
|
+ 'siimee_answered',
|
|
87
|
79
|
)
|
|
88
|
|
- this.accessToken = this.grabCookie(document.cookie, 'siimee_access')
|
|
89
|
|
- if (sessionTokenIsValid.isValid) {
|
|
90
|
|
- this.answered = {
|
|
91
|
|
- name: siimeeAnswers.name,
|
|
92
|
|
- email: siimeeAnswers.email,
|
|
93
|
|
- seeking: siimeeAnswers.seeking,
|
|
|
80
|
+ if (siimeeAnswered) {
|
|
|
81
|
+ const siimeeAnswers = JSON.parse(
|
|
|
82
|
+ this.grabCookie(document.cookie, 'siimee_answered'),
|
|
|
83
|
+ )
|
|
|
84
|
+ this.sessionToken = this.grabCookie(
|
|
|
85
|
+ document.cookie,
|
|
|
86
|
+ 'siimee_session',
|
|
|
87
|
+ )
|
|
|
88
|
+ const sessionTokenIsValid =
|
|
|
89
|
+ await this.authenticator.validateJwt(this.sessionToken)
|
|
|
90
|
+ this.accessToken = this.grabCookie(
|
|
|
91
|
+ document.cookie,
|
|
|
92
|
+ 'siimee_access',
|
|
|
93
|
+ )
|
|
|
94
|
+ if (sessionTokenIsValid.isValid) {
|
|
|
95
|
+ this.answered = {
|
|
|
96
|
+ name: siimeeAnswers.name,
|
|
|
97
|
+ email: siimeeAnswers.email,
|
|
|
98
|
+ seeking: siimeeAnswers.seeking,
|
|
|
99
|
+ }
|
|
|
100
|
+ this.currentProfileId = siimeeAnswers.profile_id
|
|
|
101
|
+ this.goToStep(6)
|
|
94
|
102
|
}
|
|
95
|
|
- this.goToStep(6)
|
|
96
|
103
|
} else this.goToStep(0)
|
|
97
|
104
|
}
|
|
98
|
105
|
},
|
|
|
@@ -106,6 +113,7 @@ export default {
|
|
106
|
113
|
}
|
|
107
|
114
|
this.currentStep = num
|
|
108
|
115
|
},
|
|
|
116
|
+ // TODO: Refactor to use cookie's max-age attribute instead of network call for jwt auth
|
|
109
|
117
|
async validateAccessToken() {
|
|
110
|
118
|
const validatedAccessToken = await this.authenticator.validateJwt(
|
|
111
|
119
|
this.accessToken,
|
|
|
@@ -138,7 +146,6 @@ export default {
|
|
138
|
146
|
return cookieKey in cookies ? cookies[`${cookieKey}`] : undefined
|
|
139
|
147
|
},
|
|
140
|
148
|
async updateAnswers(payload) {
|
|
141
|
|
- // null payload is passed on splash page
|
|
142
|
149
|
if (payload) {
|
|
143
|
150
|
// this.invalidResponse = false
|
|
144
|
151
|
const k = payload.question.survey_stage
|
|
|
@@ -150,7 +157,7 @@ export default {
|
|
150
|
157
|
}
|
|
151
|
158
|
|
|
152
|
159
|
// once validated, don't log password in answered object
|
|
153
|
|
- // this.answered[k] = k === 'password' ? undefined : payload.input
|
|
|
160
|
+ this.answered[k] = k === 'password' ? undefined : payload.input
|
|
154
|
161
|
|
|
155
|
162
|
// formats initial responses for response table
|
|
156
|
163
|
const response = {}
|
|
|
@@ -174,23 +181,6 @@ export default {
|
|
174
|
181
|
this.goToStep(this.currentStep + 1)
|
|
175
|
182
|
}
|
|
176
|
183
|
},
|
|
177
|
|
- // NOTE: Brought in from App.vue, might not be necessary...
|
|
178
|
|
- // Allows for login after initial email sign up is set
|
|
179
|
|
- async setPid(profileId) {
|
|
180
|
|
- if (currentProfile.isLoggedIn) {
|
|
181
|
|
- currentProfile.logout()
|
|
182
|
|
- }
|
|
183
|
|
- // ERROR: this._profile is undefinedin login service
|
|
184
|
|
- this.profile.id = await currentProfile.login(
|
|
185
|
|
- profileId,
|
|
186
|
|
- this.$waveui.notify,
|
|
187
|
|
- )
|
|
188
|
|
- console.log('---')
|
|
189
|
|
-
|
|
190
|
|
- // Change if survey isn't complete...
|
|
191
|
|
- // const toRoute = { name: 'HomeView' }
|
|
192
|
|
- // this.$router.push(toRoute)
|
|
193
|
|
- },
|
|
194
|
184
|
},
|
|
195
|
185
|
}
|
|
196
|
186
|
</script>
|