aboutsummaryrefslogtreecommitdiff
path: root/src/components/login_form/login_form.vue
blob: a2c5cf8fb319992ab8d92d6c7aaf63be956b4c83 (plain)
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
<template>
<div class="login panel panel-default">
  <!-- Default panel contents -->

  <div class="panel-heading">{{$t('login.login')}}</div>

  <div class="panel-body">
    <form class='login-form' @submit.prevent='submit'>
      <template v-if="isPasswordAuth">
        <div class='form-group'>
          <label for='username'>{{$t('login.username')}}</label>
          <input :disabled="loggingIn" v-model='user.username'
                 class='form-control' id='username'
                 :placeholder="$t('login.placeholder')">
        </div>
        <div class='form-group'>
          <label for='password'>{{$t('login.password')}}</label>
          <input :disabled="loggingIn" v-model='user.password'
                 ref='passwordInput' class='form-control' id='password' type='password'>
        </div>
      </template>

      <div class="form-group" v-if="isTokenAuth">
        <p>{{$t('login.description')}}</p>
      </div>

      <div class='form-group'>
        <div class='login-bottom'>
          <div>
            <router-link :to="{name: 'registration'}"
                         v-if='registrationOpen'
                         class='register'>
              {{$t('login.register')}}
            </router-link>
          </div>
          <button :disabled="loggingIn" type='submit' class='btn btn-default'>
            {{$t('login.login')}}
          </button>
        </div>
      </div>
    </form>
  </div>

  <div v-if="error" class='form-group'>
    <div class='alert error'>
      {{error}}
      <i class="button-icon icon-cancel" @click="clearError"></i>
    </div>
  </div>
</div>
</template>

<script src="./login_form.js" ></script>

<style lang="scss">
@import '../../_variables.scss';

.login-form {
  display: flex;
  flex-direction: column;
  padding: 0.6em;

  .btn {
    min-height: 28px;
    width: 10em;
  }

  .register {
    flex: 1 1;
  }

  .login-bottom {
    margin-top: 1.0em;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .form-group {
    display: flex;
    flex-direction: column;
    padding: 0.3em 0.5em 0.6em;
    line-height:24px;
  }

  .form-bottom {
    display: flex;
    padding: 0.5em;
    height: 32px;

    button {
      width: 10em;
    }

    p {
      margin: 0.35em;
      padding: 0.35em;
      display: flex;
    }
  }

  .error {
    text-align: center;

    animation-name: shakeError;
    animation-duration: 0.4s;
    animation-timing-function: ease-in-out;
  }
}
</style>