-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathLDAPLogin.vue
More file actions
95 lines (89 loc) · 2.3 KB
/
LDAPLogin.vue
File metadata and controls
95 lines (89 loc) · 2.3 KB
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
<template>
<v-card-text>
<v-form id="login_form" ref="form" name="login_form">
<v-text-field
id="username_field"
v-model="username"
:error-messages="requiredFieldError($v.username, 'Username')"
name="username"
label="Username"
prepend-icon="mdi-account"
type="text"
required
data-cy="ldapusername"
@keyup.enter="$refs.password.focus"
@blur="$v.username.$touch()"
/>
<v-text-field
id="password_field"
ref="password"
v-model="password"
:error-messages="requiredFieldError($v.password, 'Password')"
type="password"
name="password"
label="Password"
data-cy="ldappassword"
prepend-icon="mdi-lock"
@keyup.enter="ldapLogin()"
@blur="$v.password.$touch()"
/>
<v-btn
id="login_button"
depressed
large
data-cy="ldapLoginButton"
color="primary"
@click="ldapLogin()"
>
Login
</v-btn>
</v-form>
</v-card-text>
</template>
<script lang="ts">
import UserValidatorMixin from '@/mixins/UserValidatorMixin';
import {ServerModule} from '@/store/server';
import {SnackbarModule} from '@/store/snackbar';
import Vue from 'vue';
import Component from 'vue-class-component';
import {required} from 'vuelidate/lib/validators';
export interface LDAPLoginHash {
username: string;
password: string;
}
@Component({
mixins: [UserValidatorMixin],
validations: {
username: {
required
},
password: {
required
}
}
})
export default class LDAPLogin extends Vue {
username = '';
password = '';
ldapLogin() {
const creds: LDAPLoginHash = {
username: this.username,
password: this.password
};
ServerModule.LoginLDAP(creds).then(() => {
if (ServerModule.token) {
const redirectQuery = this.$route.query.redirect;
const redirectTarget = Array.isArray(redirectQuery)
? redirectQuery[0]
: redirectQuery;
const destination =
typeof redirectTarget === 'string' && redirectTarget.startsWith('/')
? redirectTarget
: '/';
this.$router.push(destination);
}
SnackbarModule.notify('You have successfully signed in.');
});
}
}
</script>