Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

LoginView.vue 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template lang="pug">
  2. main.view--login.w-full.f-col
  3. header
  4. h2 Login
  5. article
  6. form(@submit.prevent='onSubmit')
  7. label profile id:
  8. input(required='' type='profileId' v-model='form.profileId')
  9. button(type='submit') submit
  10. </template>
  11. <script>
  12. import { currentProfile } from '../services'
  13. export default {
  14. data: () => ({
  15. form: {
  16. profileId: null
  17. },
  18. }),
  19. methods: {
  20. async onSubmit() {
  21. if(!this.form.profileId) console.error('No profile in form')
  22. /**
  23. * Default to the HomeView and alter as needed (side-effects!)
  24. */
  25. const toRoute = { name: 'HomeView' }
  26. /**
  27. * Profile needs a complete survey and
  28. * alters the url if it's incomplete
  29. */
  30. const alreadyLoggedIn = await currentProfile.isLoggedIn()
  31. if(!alreadyLoggedIn) {
  32. await currentProfile.login(this.form.profileId)
  33. }
  34. this.$router.push(toRoute)
  35. },
  36. },
  37. }
  38. </script>
  39. <style lang="postcss">
  40. </style>