Kaynağa Gözat

:memo: Made notes and subtle changes for last push for survey auth

tags/0.0.3^2
tomit4 2 yıl önce
ebeveyn
işleme
529a99ed13
1 değiştirilmiş dosya ile 15 ekleme ve 18 silme
  1. 15
    18
      frontend/src/views/OnboardingView.vue

+ 15
- 18
frontend/src/views/OnboardingView.vue Dosyayı Görüntüle

@@ -73,14 +73,14 @@ export default {
73 73
             await this.verifySessionToken(sessionToken)
74 74
             const sessionData = await this.verifyAccessToken(accessToken)
75 75
             await this.isEmailInRegistry(sessionData.payload.email)
76
+            // TODO: Validate All routes hit by these methods using tokens in headers
76 77
             const userId = await this.grabUserIdByEmail(
77 78
                 sessionData.payload.email,
78 79
             )
79
-            const profileId = await this.grabProfileIdByUserId(userId)
80
-            // TODO: consider different implementation once
81
-            // updateAnswers() no longer relies on this
82
-            currentProfileId = profileId
83
-            this.responses = await this.grabResponsesByProfileId(profileId)
80
+            currentProfileId = await this.grabProfileIdByUserId(userId)
81
+            this.responses = await this.grabResponsesByProfileId(
82
+                currentProfileId,
83
+            )
84 84
             this.currentStep = this.responses.length + 3
85 85
             this.goToStep(this.currentStep)
86 86
         } catch (err) {
@@ -178,34 +178,31 @@ export default {
178 178
         },
179 179
         async updateAnswers(payload) {
180 180
             if (payload) {
181
-                // this.invalidResponse = false
182 181
                 const k = payload.question.survey_stage
183 182
                 this.answered[k] = payload.input
184
-
183
+                // Once validated, don't log password in answered object
184
+                this.answered[k] = k === 'password' ? undefined : payload.input
185
+                // Hacky WorkAround for Validating Answers
185 186
                 if (!this.survey.validateAnswer(payload)) {
186 187
                     this.invalidResponse = true
187 188
                     return
188 189
                 }
189
-
190
-                // once validated, don't log password in answered object
191
-                this.answered[k] = k === 'password' ? undefined : payload.input
192
-
193
-                // formats initial responses for response table
190
+                // Formats initial responses for response table
194 191
                 const response = {}
195 192
                 response.response_key_id = payload.question.response_key_id
196 193
                 response.val = payload.input
197 194
                 this.responses.push(response)
198
-                console.log('this.answered :=>', this.answered)
199
-                console.log('this.responses :=>', this.responses)
200 195
 
201
-                // sends latest survey response to db
196
+                // TODO: Validate this route using tokens in headers
197
+                // TODO: Set check via methods to see if tokens are still valid,
198
+                // if BOTH tokens are NOT valid,
199
+                // currentProfileId = null and this.currentStep = 0
202 200
                 if (currentProfileId) {
203
-                    surveyFactory.addNewSurveyAnswer(
201
+                    await surveyFactory.addNewSurveyAnswer(
204 202
                         this.responses[this.responses.length - 1],
205
-                        this.currentProfileId,
203
+                        currentProfileId,
206 204
                     )
207 205
                 }
208
-
209 206
                 if (k === 'aspects') return
210 207
             }
211 208
             if (this.currentStep > this.survey.steps.length) {

Loading…
İptal
Kaydet