Mercurial > gemma
annotate client/src/login/Login.vue @ 1240:9b0a7b3ea297
inport sounding results
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 20 Nov 2018 17:37:30 +0100 |
parents | ba8cd80d68b6 |
children |
rev | line source |
---|---|
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
1 (<template> |
1217
ba8cd80d68b6
made more use of bootstrap classes instead of custom css
Markus Kottlaender <markus@intevation.de>
parents:
1191
diff
changeset
|
2 <div class="d-flex flex-column login bg-white shadow"> |
ba8cd80d68b6
made more use of bootstrap classes instead of custom css
Markus Kottlaender <markus@intevation.de>
parents:
1191
diff
changeset
|
3 <div class="m-5"> |
619
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"> |
1217
ba8cd80d68b6
made more use of bootstrap classes instead of custom css
Markus Kottlaender <markus@intevation.de>
parents:
1191
diff
changeset
|
6 <div class="logo mr-3"><img src="../application/assets/logo.png"></div> |
619
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 --> |
1217
ba8cd80d68b6
made more use of bootstrap classes instead of custom css
Markus Kottlaender <markus@intevation.de>
parents:
1191
diff
changeset
|
12 <form class="loginform mx-auto" @submit.prevent="login"> |
619
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 --> |
1217
ba8cd80d68b6
made more use of bootstrap classes instead of custom css
Markus Kottlaender <markus@intevation.de>
parents:
1191
diff
changeset
|
49 <div class="mb-3 secondary-logo mx-auto mb-auto"><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 min-width: 375px |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
57 min-height: 500px |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
58 @extend %fully-centered |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
59 |
1191
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
60 .loginform |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
61 max-width: 375px |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
62 |
1191
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
63 .alert |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
64 padding: 0.5rem |
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 .secondary-logo |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
67 max-width: 375px |
616
51dc26b0f066
client: avoid extra password reveal button for IE/Edge
Bernhard Reiter <bernhard@intevation.de>
parents:
585
diff
changeset
|
68 |
51dc26b0f066
client: avoid extra password reveal button for IE/Edge
Bernhard Reiter <bernhard@intevation.de>
parents:
585
diff
changeset
|
69 /* 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
|
70 input[type="password"]::-ms-reveal |
b23622905a3f
switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents:
1139
diff
changeset
|
71 display: none |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
72 </style> |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
73 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
74 <script> |
1123
d9e6a1f6f394
moved all collapse flags for UI elements to store
Markus Kottlaender <markus@intevation.de>
parents:
1097
diff
changeset
|
75 import { mapState } from "vuex"; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
76 import { HTTP } from "../application/lib/http.js"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
77 import { displayError } from "../application/lib/errors.js"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
78 |
619
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
79 const UNAUTHORIZED = 401; |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
80 |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
81 export default { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
82 name: "login", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
83 data() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
84 return { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
85 user: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
86 password: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
87 submitted: false, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
88 loginFailed: false, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
89 passwordJustResetted: false, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
90 readablePassword: false, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
91 showPasswordReset: false, |
1061
3418f3e2c822
client: remove version number from login page
Bernhard Reiter <bernhard@intevation.de>
parents:
970
diff
changeset
|
92 usernameToReset: "" |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
93 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
94 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
95 computed: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
96 errorMessage() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
97 if (this.loginFailed) return this.$gettext("Login failed"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
98 if (this.passwordJustResetted) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
99 return this.$gettext("Password reset requested!"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
100 return "&npsp;"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
101 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
102 passwordLabel() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
103 return this.$gettext("Enter passphrase"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
104 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
105 usernameLabel() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
106 return this.$gettext("Enter username"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
107 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
108 isPasswordVisible() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
109 return this.readablePassword ? "text" : "password"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
110 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
111 errorMessageStyle() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
112 if (this.loginFailed || this.passwordJustResetted) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
113 return "visibility:visible"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
114 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
115 return "visibility:hidden"; |
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 errorMessageClass() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
118 let result = { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
119 "mb-3": true, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
120 errormessage: true, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
121 alert: true |
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 if (this.loginFailed) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
124 result["alert-danger"] = true; |
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 if (this.passwordJustResetted) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
127 result["alert-info"] = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
128 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
129 return result; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
130 }, |
1123
d9e6a1f6f394
moved all collapse flags for UI elements to store
Markus Kottlaender <markus@intevation.de>
parents:
1097
diff
changeset
|
131 ...mapState("application", ["appTitle", "secondaryLogo"]) |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
132 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
133 methods: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
134 login() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
135 this.submitted = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
136 this.passwordJustResetted = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
137 const { user, password } = this; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
138 this.$store |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
139 .dispatch("user/login", { user, password }) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
140 .then(() => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
141 this.loginFailed = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
142 this.$router.push("/"); |
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 .catch(error => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
145 this.loginFailed = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
146 this.submitted = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
147 const { status, data } = error.response; |
619
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
148 if (status !== UNAUTHORIZED) { |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
149 //Unauthorized is handled in alert-div |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
150 displayError({ |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
151 title: "Backend Error", |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
152 message: `${status}: ${data.message || data}` |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
153 }); |
6af5f8fee3a3
fix: No toast for unauthorized login
Thomas Junk <thomas.junk@intevation.de>
parents:
616
diff
changeset
|
154 } |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
155 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
156 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
157 showPassword() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
158 // disallowing toggle when in reset mode |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
159 if (this.showPasswordReset) return; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
160 this.readablePassword = !this.readablePassword; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
161 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
162 togglePasswordReset() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
163 this.passwordJustResetted = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
164 this.showPasswordReset = !this.showPasswordReset; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
165 this.loginFailed = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
166 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
167 resetPassword() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
168 if (this.user) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
169 HTTP.post("/users/passwordreset", { user: this.user }).catch(error => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
170 const { status, data } = error.response; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
171 displayError({ |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
172 title: "Backend Error", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
173 message: `${status}: ${data.message || data}` |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
174 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
175 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
176 this.togglePasswordReset(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
177 this.passwordJustResetted = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
178 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
179 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
180 } |
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 </script> |