Bladeren bron

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

tags/0.0.3^2
tomit4 2 jaren geleden
bovenliggende
commit
529a99ed13
1 gewijzigde bestanden met toevoegingen van 15 en 18 verwijderingen
  1. 15
    18
      frontend/src/views/OnboardingView.vue

+ 15
- 18
frontend/src/views/OnboardingView.vue Bestand weergeven

73
             await this.verifySessionToken(sessionToken)
73
             await this.verifySessionToken(sessionToken)
74
             const sessionData = await this.verifyAccessToken(accessToken)
74
             const sessionData = await this.verifyAccessToken(accessToken)
75
             await this.isEmailInRegistry(sessionData.payload.email)
75
             await this.isEmailInRegistry(sessionData.payload.email)
76
+            // TODO: Validate All routes hit by these methods using tokens in headers
76
             const userId = await this.grabUserIdByEmail(
77
             const userId = await this.grabUserIdByEmail(
77
                 sessionData.payload.email,
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
             this.currentStep = this.responses.length + 3
84
             this.currentStep = this.responses.length + 3
85
             this.goToStep(this.currentStep)
85
             this.goToStep(this.currentStep)
86
         } catch (err) {
86
         } catch (err) {
178
         },
178
         },
179
         async updateAnswers(payload) {
179
         async updateAnswers(payload) {
180
             if (payload) {
180
             if (payload) {
181
-                // this.invalidResponse = false
182
                 const k = payload.question.survey_stage
181
                 const k = payload.question.survey_stage
183
                 this.answered[k] = payload.input
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
                 if (!this.survey.validateAnswer(payload)) {
186
                 if (!this.survey.validateAnswer(payload)) {
186
                     this.invalidResponse = true
187
                     this.invalidResponse = true
187
                     return
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
                 const response = {}
191
                 const response = {}
195
                 response.response_key_id = payload.question.response_key_id
192
                 response.response_key_id = payload.question.response_key_id
196
                 response.val = payload.input
193
                 response.val = payload.input
197
                 this.responses.push(response)
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
                 if (currentProfileId) {
200
                 if (currentProfileId) {
203
-                    surveyFactory.addNewSurveyAnswer(
201
+                    await surveyFactory.addNewSurveyAnswer(
204
                         this.responses[this.responses.length - 1],
202
                         this.responses[this.responses.length - 1],
205
-                        this.currentProfileId,
203
+                        currentProfileId,
206
                     )
204
                     )
207
                 }
205
                 }
208
-
209
                 if (k === 'aspects') return
206
                 if (k === 'aspects') return
210
             }
207
             }
211
             if (this.currentStep > this.survey.steps.length) {
208
             if (this.currentStep > this.survey.steps.length) {

Laden…
Annuleren
Opslaan