Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

VerifyView.vue 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template lang="pug">
  2. .wait-message
  3. p.verify-message Thanks for authenticating your email!
  4. p.verify-message Please give us a moment to redirect you back to the survey
  5. </template>
  6. <script>
  7. import { Authenticator } from '../services/auth.service.js'
  8. export default {
  9. name: 'VerifyView',
  10. data: () => ({
  11. authenticator: {},
  12. }),
  13. async created() {
  14. this.authenticator = new Authenticator()
  15. const hashEmail = this.$route.params.email
  16. const hashesMatch = await this.authenticator.verifyAuthEmail(hashEmail)
  17. const siimeeToken = this.grabToken(document.cookie)
  18. // TODO: remove once currentProfile is established and user is logged in...
  19. // NOTE: another siimee_jwt cookie for onboarding path instead of verify
  20. document.cookie = `siimee_jwt=${siimeeToken}; path=/onboarding`
  21. const jwt = await this.authenticator.validateJwt(siimeeToken)
  22. if (jwt.isValid && hashesMatch) {
  23. // TODO: set jwt.payload.profile_id as siimee_profile_id
  24. // remove answers, will query db at SurveyCompleteView.vue
  25. const siimeeAnswers = JSON.stringify(jwt.payload)
  26. document.cookie = `siimee_answered=${siimeeAnswers} ; path=/onboarding`
  27. this.$router.push('/onboarding')
  28. }
  29. // else {
  30. // render ERROR message above or redirect to 404 (or both?)
  31. },
  32. methods: {
  33. grabToken(cookieString) {
  34. const cookies = cookieString.split('; ').reduce((prev, current) => {
  35. const [name, ...value] = current.split('=')
  36. prev[name] = value.join('=')
  37. return prev
  38. }, {})
  39. return 'siimee_jwt' in cookies ? cookies['siimee_jwt'] : undefined
  40. },
  41. },
  42. }
  43. </script>
  44. <style>
  45. .wait-message {
  46. margin: 5rem auto;
  47. text-align: center;
  48. width: 90%;
  49. max-width: 35rem;
  50. font-size: 150%;
  51. font-weight: bold;
  52. }
  53. </style>