Mercurial > gemma
annotate client/src/login/Login.vue @ 1191:b23622905a3f
switched entirely to sass instead of scss
for cleaner code/less lines, just removed all ; and {}
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Fri, 16 Nov 2018 14:37:07 +0100 |
parents | 2fda33d55d81 |
children | ba8cd80d68b6 |
rev | line source |
---|---|
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
1 (<template> |
619
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
2 <div class="d-flex flex-column login shadow-lg"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
3 <div class="loginmask"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
4 <!-- logo section --> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
5 <div class="d-flex flex-row justify-content-center mb-3"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
6 <div class="logo"><img src="../application/assets/logo.png"></div> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
7 <div class="title"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
8 <h1>{{ appTitle }}</h1> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
9 </div> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
10 </div> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
11 <!-- end logo section --> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
12 <form class="loginform" @submit.prevent="login"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
13 <div id="alert" :style="errorMessageStyle" :class="errorMessageClass" role="alert"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
14 <span>{{ errorMessage }}</span> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
15 </div> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
16 <div class="input-group mb-3"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
17 <input type="text" v-model="user" id="inputUsername" class="form-control shadow-sm" :placeholder="usernameLabel" required autofocus> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
18 </div> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
19 <div class="input-group mb-3"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
20 <input :type="isPasswordVisible" v-model="password" id="inputPassword" class="form-control shadow-sm" :placeholder='passwordLabel' :required='!showPasswordReset' :disabled='showPasswordReset'> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
21 <div class="input-group-append"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
22 <span class="input-group-text disabled" id="basic-addon2" @click="showPassword"> |
1097
874d19f32015
added fontawesome5 and implemented one example icon on login screen
Markus Kottlaender <markus@intevation.de>
parents:
1061
diff
changeset
|
23 <font-awesome-icon icon="eye" v-if="!readablePassword" /> |
874d19f32015
added fontawesome5 and implemented one example icon on login screen
Markus Kottlaender <markus@intevation.de>
parents:
1061
diff
changeset
|
24 <font-awesome-icon icon="eye-slash" v-if="readablePassword" /> |
619
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
25 </span> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
26 </div> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
27 </div> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
28 <button v-if="showPasswordReset==false" class="btn btn-primary btn-block shadow-sm" :disabled="submitted || showPasswordReset" type="submit"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
29 <translate>Login</translate> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
30 </button> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
31 <div v-if="showPasswordReset" class="passwordreset"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
32 <button class="btn btn-block btn-info" type="button" @click="resetPassword"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
33 <translate>Request password reset!</translate> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
34 </button> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
35 <div class="pull-right"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
36 <a href="#" @click.prevent="togglePasswordReset"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
37 <translate>back to login</translate> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
38 </a> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
39 </div> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
40 </div> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
41 <div v-else class="pull-right"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
42 <a href="#" @click.prevent="togglePasswordReset"> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
43 <translate>Forgot password</translate> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
44 </a> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
45 </div> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
46 </form> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
47 |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
48 <!-- bottom logo section --> |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
49 <div class="mb-3 secondary-logo"><img :src="secondaryLogo"></div> |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
50 </div> |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
51 </div> |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
52 </template>) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
53 |
1191
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
54 <style lang="sass" scoped> |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
55 .login |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
56 background-color: white |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
57 min-width: 375px |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
58 min-height: 500px |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
59 @extend %fully-centered |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
60 |
1191
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
61 .loginform |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
62 max-width: 375px |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
63 margin-left: auto |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
64 margin-right: auto |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
65 |
1191
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
66 .loginmask |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
67 position: relative |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
68 margin-left: $large-offset |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
69 margin-right: $large-offset |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
70 margin-top: $large-offset |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
71 |
1191
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
72 .logo |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
73 margin-right: $offset |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
74 |
1191
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
75 .alert |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
76 padding: 0.5rem |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
77 |
1191
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
78 .secondary-logo |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
79 max-width: 375px |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
80 margin-left: auto |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
81 margin-right: auto |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
82 margin-bottom: auto |
616
51dc26b0f066
client: avoid extra password reveal button for IE/Edge
Bernhard Reiter <bernhard@intevation.de>
parents:
585
diff
changeset
|
83 |
51dc26b0f066
client: avoid extra password reveal button for IE/Edge
Bernhard Reiter <bernhard@intevation.de>
parents:
585
diff
changeset
|
84 /* avoid IE and Edge show a password reveal as we do our own */ |
1191
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
85 input[type="password"]::-ms-reveal |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
86 display: none |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
87 </style> |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
88 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
89 <script> |
1123
d9e6a1f6f394
moved all collapse flags for UI elements to store
Markus Kottlaender <markus@intevation.de>
parents:
1097
diff
changeset
|
90 import { mapState } from "vuex"; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
91 import { HTTP } from "../application/lib/http.js"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
92 import { displayError } from "../application/lib/errors.js"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
93 |
619
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
94 const UNAUTHORIZED = 401; |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
95 |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
96 export default { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
97 name: "login", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
98 data() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
99 return { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
100 user: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
101 password: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
102 submitted: false, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
103 loginFailed: false, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
104 passwordJustResetted: false, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
105 readablePassword: false, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
106 showPasswordReset: false, |
1061
3418f3e2c822
client: remove version number from login page
Bernhard Reiter <bernhard@intevation.de>
parents:
970
diff
changeset
|
107 usernameToReset: "" |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
108 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
109 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
110 computed: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
111 errorMessage() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
112 if (this.loginFailed) return this.$gettext("Login failed"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
113 if (this.passwordJustResetted) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
114 return this.$gettext("Password reset requested!"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
115 return "&npsp;"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
116 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
117 passwordLabel() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
118 return this.$gettext("Enter passphrase"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
119 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
120 usernameLabel() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
121 return this.$gettext("Enter username"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
122 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
123 isPasswordVisible() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
124 return this.readablePassword ? "text" : "password"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
125 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
126 errorMessageStyle() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
127 if (this.loginFailed || this.passwordJustResetted) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
128 return "visibility:visible"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
129 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
130 return "visibility:hidden"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
131 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
132 errorMessageClass() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
133 let result = { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
134 "mb-3": true, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
135 errormessage: true, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
136 alert: true |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
137 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
138 if (this.loginFailed) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
139 result["alert-danger"] = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
140 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
141 if (this.passwordJustResetted) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
142 result["alert-info"] = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
143 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
144 return result; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
145 }, |
1123
d9e6a1f6f394
moved all collapse flags for UI elements to store
Markus Kottlaender <markus@intevation.de>
parents:
1097
diff
changeset
|
146 ...mapState("application", ["appTitle", "secondaryLogo"]) |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
147 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
148 methods: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
149 login() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
150 this.submitted = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
151 this.passwordJustResetted = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
152 const { user, password } = this; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
153 this.$store |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
154 .dispatch("user/login", { user, password }) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
155 .then(() => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
156 this.loginFailed = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
157 this.$router.push("/"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
158 }) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
159 .catch(error => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
160 this.loginFailed = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
161 this.submitted = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
162 const { status, data } = error.response; |
619
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
163 if (status !== UNAUTHORIZED) { |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
164 //Unauthorized is handled in alert-div |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
165 displayError({ |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
166 title: "Backend Error", |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
167 message: `${status}: ${data.message || data}` |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
168 }); |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
169 } |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
170 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
171 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
172 showPassword() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
173 // disallowing toggle when in reset mode |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
174 if (this.showPasswordReset) return; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
175 this.readablePassword = !this.readablePassword; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
176 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
177 togglePasswordReset() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
178 this.passwordJustResetted = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
179 this.showPasswordReset = !this.showPasswordReset; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
180 this.loginFailed = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
181 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
182 resetPassword() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
183 if (this.user) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
184 HTTP.post("/users/passwordreset", { user: this.user }).catch(error => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
185 const { status, data } = error.response; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
186 displayError({ |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
187 title: "Backend Error", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
188 message: `${status}: ${data.message || data}` |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
189 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
190 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
191 this.togglePasswordReset(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
192 this.passwordJustResetted = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
193 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
194 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
195 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
196 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
197 </script> |