2020-10-10 21:02:32 +00:00
|
|
|
<template>
|
2021-02-10 17:09:37 +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">
|
2021-02-10 17:09:37 +00:00
|
|
|
<q-toolbar-title> Login </q-toolbar-title>
|
2020-10-10 21:02:32 +00:00
|
|
|
</q-toolbar>
|
|
|
|
|
|
|
|
<q-card-section>
|
2021-03-31 15:22:55 +00:00
|
|
|
<q-form class="q-gutter-md" @submit="doLogin">
|
2020-10-10 21:02:32 +00:00
|
|
|
<q-input
|
2020-10-15 01:36:25 +00:00
|
|
|
v-model="userid"
|
2021-02-01 23:48:33 +00:00
|
|
|
filled
|
2020-10-10 21:02:32 +00:00
|
|
|
label="Benutzername oder E-Mail"
|
2021-03-31 15:22:55 +00:00
|
|
|
autocomplete="username"
|
|
|
|
:rules="[notEmpty]"
|
2021-01-18 15:05:05 +00:00
|
|
|
tabindex="1"
|
2020-10-10 21:02:32 +00:00
|
|
|
/>
|
2021-03-31 15:22:55 +00:00
|
|
|
<password-input
|
2020-10-10 21:02:32 +00:00
|
|
|
v-model="password"
|
2021-02-01 23:48:33 +00:00
|
|
|
filled
|
2021-03-31 15:22:55 +00:00
|
|
|
label="Passwort"
|
|
|
|
autocomplete="cureent-password"
|
|
|
|
:rules="[notEmpty]"
|
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"
|
|
|
|
color="secondary"
|
|
|
|
tabindex="4"
|
2021-02-01 23:48:33 +00:00
|
|
|
@click="doReset"
|
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>
|
2021-01-29 13:06:25 +00:00
|
|
|
<div class="row justify-end">
|
2021-04-17 10:36:19 +00:00
|
|
|
<q-btn v-if='$q.platform.is.cordova || $q.platform.is.electron' flat round icon="mdi-menu-down" @click="openServerSettings" />
|
2021-01-29 13:06:25 +00:00
|
|
|
</div>
|
2021-04-17 10:36:19 +00:00
|
|
|
<q-slide-transition v-if='$q.platform.is.cordova || $q.platform.is.electron'>
|
2021-01-29 19:10:53 +00:00
|
|
|
<div v-show="visible">
|
|
|
|
<q-separator />
|
|
|
|
<q-card-section>
|
2021-02-01 23:48:33 +00:00
|
|
|
<q-form ref="ServerSettingsForm" class="q-gutter-md" @submit="changeUrl">
|
2021-01-29 19:10:53 +00:00
|
|
|
<div class="text-h6">Servereinstellung</div>
|
2021-02-01 23:48:33 +00:00
|
|
|
<q-input v-model="server" filled label="Server" dense />
|
2021-01-29 19:10:53 +00:00
|
|
|
<q-btn size="xs" dense color="primary" label="Speichern" type="submit" />
|
|
|
|
</q-form>
|
|
|
|
</q-card-section>
|
|
|
|
</div>
|
2021-01-29 13:06:25 +00:00
|
|
|
</q-slide-transition>
|
2020-10-10 21:02:32 +00:00
|
|
|
</q-card>
|
|
|
|
</q-page>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-01-30 05:19:43 +00:00
|
|
|
import { useRouter } from 'vue-router';
|
2020-11-16 13:17:26 +00:00
|
|
|
import { Loading, Notify } from 'quasar';
|
2021-03-31 15:22:55 +00:00
|
|
|
import { useMainStore } from 'src/stores';
|
2021-01-30 05:19:43 +00:00
|
|
|
import { defineComponent, ref } from 'vue';
|
2021-02-02 21:32:23 +00:00
|
|
|
import { setBaseURL, api } from 'boot/axios';
|
2021-03-31 15:22:55 +00:00
|
|
|
import { notEmpty } from 'src/utils/validators';
|
2021-02-02 21:32:23 +00:00
|
|
|
import { useUserStore } from 'src/plugins/user/store';
|
2021-03-31 15:22:55 +00:00
|
|
|
import PasswordInput from 'src/components/utils/PasswordInput.vue';
|
2021-04-17 10:36:19 +00:00
|
|
|
import { useQuasar } from 'quasar';
|
2020-10-10 21:02:32 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
2021-02-02 21:32:23 +00:00
|
|
|
name: 'Login',
|
2021-03-31 15:22:55 +00:00
|
|
|
components: { PasswordInput },
|
2021-01-30 05:19:43 +00:00
|
|
|
setup() {
|
2021-02-02 21:32:23 +00:00
|
|
|
const mainStore = useMainStore();
|
2020-11-10 00:33:55 +00:00
|
|
|
const mainRoute = { name: 'dashboard' };
|
2021-02-02 21:32:23 +00:00
|
|
|
const router = useRouter();
|
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-30 05:19:43 +00:00
|
|
|
const server = ref<string | undefined>(api.defaults.baseURL);
|
2021-01-29 13:06:25 +00:00
|
|
|
const visible = ref(false);
|
2021-04-17 10:36:19 +00:00
|
|
|
const $q = useQuasar()
|
2021-01-29 13:06:25 +00:00
|
|
|
|
|
|
|
function openServerSettings() {
|
2021-01-29 19:10:53 +00:00
|
|
|
visible.value = !visible.value;
|
2021-01-29 13:06:25 +00:00
|
|
|
}
|
2021-01-29 10:51:56 +00:00
|
|
|
|
|
|
|
function changeUrl() {
|
|
|
|
if (server.value) {
|
2021-02-02 21:32:23 +00:00
|
|
|
setBaseURL(server.value);
|
2021-01-29 10:51:56 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-10 21:02:32 +00:00
|
|
|
|
2021-02-02 21:32:23 +00:00
|
|
|
async function doLogin() {
|
|
|
|
Loading.show({ message: 'Du wirst angemeldet' });
|
|
|
|
const status = await mainStore.login(userid.value, password.value);
|
|
|
|
|
|
|
|
if (status === true) {
|
2021-04-18 20:33:32 +00:00
|
|
|
mainStore.user = (await useUserStore().getUser(userid.value, true)) || undefined;
|
2021-02-02 21:32:23 +00:00
|
|
|
const x = router.currentRoute.value.query['redirect'];
|
|
|
|
void router.push(typeof x === 'string' ? { path: x } : mainRoute);
|
|
|
|
} else {
|
|
|
|
password.value = '';
|
|
|
|
if (status === 401) {
|
|
|
|
Notify.create({
|
|
|
|
group: false,
|
|
|
|
type: 'negative',
|
|
|
|
message: 'Benutzername oder Passwort sind falsch.',
|
|
|
|
timeout: 10000,
|
|
|
|
progress: true,
|
|
|
|
actions: [{ icon: 'mdi-close', color: 'white' }],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Loading.hide();
|
2020-10-10 21:02:32 +00:00
|
|
|
}
|
|
|
|
|
2021-02-02 21:32:23 +00:00
|
|
|
async function doReset() {
|
2021-01-18 15:05:05 +00:00
|
|
|
if (userid.value == '') {
|
|
|
|
Notify.create({
|
|
|
|
group: false,
|
|
|
|
type: 'negative',
|
|
|
|
message: 'Der Benutzername darf nicht leer sein.',
|
|
|
|
timeout: 10000,
|
|
|
|
progress: true,
|
2021-03-18 16:23:57 +00:00
|
|
|
actions: [{ icon: 'mdi-close', color: 'white' }],
|
2021-01-18 15:05:05 +00:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
2021-02-02 21:32:23 +00:00
|
|
|
|
|
|
|
if (await mainStore.requestReset(userid.value)) {
|
|
|
|
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' }],
|
2021-01-18 15:05:05 +00:00
|
|
|
});
|
2021-02-02 21:32:23 +00:00
|
|
|
}
|
2021-01-18 15:05:05 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 19:10:53 +00:00
|
|
|
return {
|
2021-03-31 15:22:55 +00:00
|
|
|
changeUrl,
|
2021-01-29 19:10:53 +00:00
|
|
|
doLogin,
|
|
|
|
doReset,
|
2021-03-31 15:22:55 +00:00
|
|
|
notEmpty,
|
|
|
|
openServerSettings,
|
|
|
|
password,
|
2021-01-29 19:10:53 +00:00
|
|
|
server,
|
2021-03-31 15:22:55 +00:00
|
|
|
userid,
|
2021-01-29 19:10:53 +00:00
|
|
|
visible,
|
2021-04-17 10:36:19 +00:00
|
|
|
$q
|
2021-01-29 19:10:53 +00:00
|
|
|
};
|
2021-03-18 16:23:57 +00:00
|
|
|
},
|
2020-10-10 21:02:32 +00:00
|
|
|
});
|
|
|
|
</script>
|