2020-10-10 21:02:32 +00:00
|
|
|
<template>
|
2021-01-18 15:05:05 +00:00
|
|
|
<q-page padding class="fit row justify-center items-center content-center">
|
2020-11-16 13:17:26 +00:00
|
|
|
<q-card class="col-xs-11 col-sm-8 col-md-6 col-lg-4 justify-center items-center content-center">
|
2020-10-10 21:02:32 +00:00
|
|
|
<q-toolbar class="bg-primary text-white">
|
|
|
|
<q-toolbar-title>
|
|
|
|
Login
|
|
|
|
</q-toolbar-title>
|
|
|
|
</q-toolbar>
|
|
|
|
|
|
|
|
<q-card-section>
|
2021-01-18 15:05:05 +00:00
|
|
|
<q-form ref="LoginForm" @submit="doLogin" class="q-gutter-md">
|
2020-10-10 21:02:32 +00:00
|
|
|
<q-input
|
|
|
|
filled
|
2020-10-15 01:36:25 +00:00
|
|
|
v-model="userid"
|
2020-10-10 21:02:32 +00:00
|
|
|
label="Benutzername oder E-Mail"
|
|
|
|
:rules="rules"
|
2021-01-18 15:05:05 +00:00
|
|
|
tabindex="1"
|
2020-10-10 21:02:32 +00:00
|
|
|
/>
|
|
|
|
<q-input
|
|
|
|
filled
|
|
|
|
v-model="password"
|
|
|
|
type="password"
|
|
|
|
label="Password"
|
|
|
|
:rules="rules"
|
2021-01-18 15:05:05 +00:00
|
|
|
tabindex="2"
|
2020-10-10 21:02:32 +00:00
|
|
|
/>
|
2021-01-18 15:05:05 +00:00
|
|
|
<div class="row justify-between">
|
2020-11-16 13:17:26 +00:00
|
|
|
<q-btn
|
2021-01-18 15:05:05 +00:00
|
|
|
label="Passwort vergessen"
|
|
|
|
type="a"
|
|
|
|
@click="doReset"
|
|
|
|
color="secondary"
|
|
|
|
tabindex="4"
|
2020-11-16 13:17:26 +00:00
|
|
|
/>
|
2021-01-18 15:05:05 +00:00
|
|
|
<q-btn label="Login" type="submit" color="primary" tabindex="3" />
|
2020-10-10 21:02:32 +00:00
|
|
|
</div>
|
|
|
|
</q-form>
|
|
|
|
</q-card-section>
|
|
|
|
</q-card>
|
|
|
|
</q-page>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent, ref } from '@vue/composition-api';
|
2020-11-16 13:17:26 +00:00
|
|
|
import { Loading, Notify } from 'quasar';
|
2020-10-10 21:02:32 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
// name: 'PageName'
|
2020-11-06 00:12:03 +00:00
|
|
|
setup(_, { root }) {
|
2020-11-10 00:33:55 +00:00
|
|
|
const mainRoute = { name: 'dashboard' };
|
2020-11-09 02:40:51 +00:00
|
|
|
|
|
|
|
/* Stuff for the real login page */
|
2020-10-15 01:36:25 +00:00
|
|
|
const userid = ref('');
|
2020-10-10 21:02:32 +00:00
|
|
|
const password = ref('');
|
2021-01-18 15:05:05 +00:00
|
|
|
const rules = [(val: string) => (val && val.length > 0) || 'Feld darf nicht leer sein!'];
|
2020-10-10 21:02:32 +00:00
|
|
|
|
|
|
|
function doLogin() {
|
2020-11-09 02:40:51 +00:00
|
|
|
Loading.show({
|
2021-01-18 15:05:05 +00:00
|
|
|
message: 'Du wirst angemeldet'
|
2020-11-09 02:40:51 +00:00
|
|
|
});
|
2020-11-06 00:12:03 +00:00
|
|
|
root.$store
|
2020-11-04 22:53:10 +00:00
|
|
|
.dispatch('session/login', {
|
2020-10-28 23:10:45 +00:00
|
|
|
userid: userid.value,
|
2021-01-18 15:05:05 +00:00
|
|
|
password: password.value
|
2020-10-28 23:10:45 +00:00
|
|
|
})
|
2020-11-09 02:40:51 +00:00
|
|
|
.then(() => {
|
|
|
|
const x = root.$route.query['redirect'];
|
2021-01-18 15:05:05 +00:00
|
|
|
void root.$router.push(typeof x === 'string' ? { path: x } : mainRoute);
|
2020-11-09 02:40:51 +00:00
|
|
|
})
|
2020-11-16 13:17:26 +00:00
|
|
|
.catch((error: { status: number } | undefined) => {
|
|
|
|
if (error && error.status === 401) {
|
|
|
|
password.value = '';
|
|
|
|
Notify.create({
|
|
|
|
group: false,
|
|
|
|
type: 'negative',
|
|
|
|
message: 'Benutzername oder Passwort sind falsch.',
|
|
|
|
timeout: 10000,
|
|
|
|
progress: true,
|
2021-01-18 15:05:05 +00:00
|
|
|
actions: [{ icon: 'mdi-close', color: 'white' }]
|
2020-11-16 13:17:26 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
2020-11-09 02:40:51 +00:00
|
|
|
.finally(() => {
|
|
|
|
Loading.hide();
|
2020-10-28 23:10:45 +00:00
|
|
|
});
|
2020-10-10 21:02:32 +00:00
|
|
|
}
|
|
|
|
|
2021-01-18 15:05:05 +00:00
|
|
|
function doReset() {
|
|
|
|
if (userid.value == '') {
|
|
|
|
Notify.create({
|
|
|
|
group: false,
|
|
|
|
type: 'negative',
|
|
|
|
message: 'Der Benutzername darf nicht leer sein.',
|
|
|
|
timeout: 10000,
|
|
|
|
progress: true,
|
|
|
|
actions: [{ icon: 'mdi-close', color: 'white' }]
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
root.$store
|
|
|
|
.dispatch('session/requestPasswordReset', {
|
|
|
|
userid: userid.value
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
userid.value = '';
|
|
|
|
password.value = '';
|
|
|
|
Notify.create({
|
|
|
|
group: false,
|
|
|
|
type: 'ongoing',
|
|
|
|
message:
|
|
|
|
'Sollte der Benutzername korrekt und vorhanden sein, erhälst du jetzt eine E-Mail.',
|
|
|
|
timeout: 10000,
|
|
|
|
progress: true,
|
|
|
|
actions: [{ icon: 'mdi-close', color: 'white' }]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return { userid, password, doLogin, doReset, rules };
|
|
|
|
}
|
2020-10-10 21:02:32 +00:00
|
|
|
});
|
|
|
|
</script>
|