Explorar el Código

:construction: Small optimization for authenticator, note in guards.js

tags/0.0.4
tomit4 hace 2 años
padre
commit
bacb460867
Se han modificado 2 ficheros con 4 adiciones y 5 borrados
  1. 1
    0
      frontend/src/router/guards.js
  2. 3
    5
      frontend/src/views/OnboardingView.vue

+ 1
- 0
frontend/src/router/guards.js Ver fichero

13
     }
13
     }
14
 }
14
 }
15
 
15
 
16
+// TODO: move to utils/index.js and import to this file, OnboardingView.vue and VerifyView.vue
16
 const grabStoredCookie = cookieKey => {
17
 const grabStoredCookie = cookieKey => {
17
     const cookies = document.cookie.split('; ').reduce((prev, current) => {
18
     const cookies = document.cookie.split('; ').reduce((prev, current) => {
18
         const [name, ...value] = current.split('=')
19
         const [name, ...value] = current.split('=')

+ 3
- 5
frontend/src/views/OnboardingView.vue Ver fichero

30
             p(v-if='currentStep != 0') You have completed: {{ currentStep }} / {{ survey?.steps?.length }} survey steps
30
             p(v-if='currentStep != 0') You have completed: {{ currentStep }} / {{ survey?.steps?.length }} survey steps
31
 
31
 
32
     article(v-else)
32
     article(v-else)
33
-        SurveyCompleteView(:answers='answered' :surveySteps='survey?.steps')
33
+        SurveyCompleteView(:answers='answered' :surveySteps='survey.steps' :responses='responses')
34
 </template>
34
 </template>
35
 
35
 
36
 <script>
36
 <script>
37
-import { currentProfile, Authenticator } from '../services'
37
+import { currentProfile, authenticator } from '../services'
38
 import { surveyFactory } from '@/utils'
38
 import { surveyFactory } from '@/utils'
39
 import stepViews from '@/components/onboarding'
39
 import stepViews from '@/components/onboarding'
40
 import SurveyCompleteView from './SurveyCompleteView.vue'
40
 import SurveyCompleteView from './SurveyCompleteView.vue'
53
         currentStep: 0,
53
         currentStep: 0,
54
         survey: null,
54
         survey: null,
55
         invalidResponse: false,
55
         invalidResponse: false,
56
-        authenticator: {},
57
     }),
56
     }),
58
     async created() {
57
     async created() {
59
         this.survey = await surveyFactory.createSurvey()
58
         this.survey = await surveyFactory.createSurvey()
60
-        this.authenticator = new Authenticator()
61
         hashedAccessToken = this.grabStoredCookie('siimee_access')
59
         hashedAccessToken = this.grabStoredCookie('siimee_access')
62
         console.log('currentProfile.isLoggedIn :=>', currentProfile.isLoggedIn)
60
         console.log('currentProfile.isLoggedIn :=>', currentProfile.isLoggedIn)
63
         try {
61
         try {
99
         async verifySession(hashedAccessToken) {
97
         async verifySession(hashedAccessToken) {
100
             if (!hashedAccessToken)
98
             if (!hashedAccessToken)
101
                 return console.warn('WARNING :=> accessToken is not defined')
99
                 return console.warn('WARNING :=> accessToken is not defined')
102
-            const validatedToken = await this.authenticator.validateSession(
100
+            const validatedToken = await authenticator.validateSession(
103
                 hashedAccessToken,
101
                 hashedAccessToken,
104
             )
102
             )
105
             if (validatedToken.error) {
103
             if (validatedToken.error) {

Loading…
Cancelar
Guardar