All files / pages register.vue

0% Statements 0/9
0% Branches 0/4
0% Functions 0/3
0% Lines 0/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155                                                                                                                                                                                                                                                                                                                     
<template lang="pug">
  .container(:class="{registered}")
    //TODO: "email already taken" / "username already taken" / "password too weak" cases
    OverlayLoadingLogo.logo(animation="animate-in-compound")
    template(v-if="!registered")
      .login-link
        p
          | Déjà un compte ?
          ButtonNormal(smaller variant="outline" href="/login") Connectez-vous
      form(method="post" @submit.prevent="register")
        .group-left
          InputField(
            name="username"
            v-model="username"
            v-bind="{validation}"
            tabindex="1"
          ) Nom d'utilisateur
          InputField(
            name="email"
            v-model="email"
            v-bind="{validation}"
            tabindex="2"
          ) Adresse email
        .group-right
          InputField(
            type="password"
            v-model="password"
            v-bind="{validation}"
            tabindex="3"
          ) Mot de passe
          InputField(
            type="password"
            name="password-confirmation"
            v-model="passwordConfirmation"
            v-bind="{validation}"
            tabindex="4"
          ) Confirmer le mot de passe
        .group-both
          ButtonNormal.submit(variant="primary" v-bind="{validation}" type="submit") Créez votre compte
    template(v-else)
      .registered
        img(src="/misc/checkmark.svg")
        .text
          p
            | Vous voici fin prêt, 
            wbr
            span.username {{ username }}
            |.
          ButtonNormal.cta(href="/login" variant="primary") Connectez-vous
 
</template>
 
<script>
import { mapGetters, mapActions } from 'vuex'
import OverlayLoadingLogo from '~/components/legacy/OverlayLoadingLogo.vue'
import InputField from '~/components/legacy/InputField.vue'
import ButtonNormal from '~/components/legacy/ButtonNormal.vue'
 
export default {
  layout: 'bare',
  auth: 'guest', // Disable auth requirements
  components: { OverlayLoadingLogo, InputField, ButtonNormal },
  data() {
    return {
      username: '',
      email: '',
      password: '',
      passwordConfirmation: '',
      registered: false,
    }
  },
  computed: {
    validation() {
      return this.validateRegister()(this)
    },
  },
  methods: {
    ...mapGetters('auth', ['validateRegister']),
    ...mapActions('auth', { _register: 'register' }),
    async register() {
      this.registered = await this._register({
        email: this.email,
        username: this.username,
        password: this.password,
      })
    },
  },
}
</script>
 
<style lang="stylus" scoped>
.container
  display flex
  flex-direction column
  justify-content center
  align-items center
  min-width 100vw
  min-height 100vh
  text-align center
 
@media (min-width: calc(888px + 1px))
  form
    display grid
    grid-template-columns repeat(2, 1fr)
    grid-gap 2em
 
  .group-both
    display flex
    justify-content center
    width 100%
    grid-column 1 / span 2
 
.login-link
  margin-bottom 4em
 
.forgotten-password
  margin-top 2em
 
.submit
  margin-top 1em
 
.field
  width 300px
 
.registered
  display flex
  align-items center
 
  @media (max-width: 888px)
    flex-direction column
    justify-content center
 
    img
      width 90vw
 
  p
    font-size 1.5rem
    line-height 1.2em
 
  .text
    text-align left
 
    @media (max-width: 888px)
      text-align center
 
    max-width 20em
 
    & /deep/ .btn
      margin-top 2em
 
@media (max-width: 888px)
  .registered .logo
    display none
</style>