Login Done

This commit is contained in:
2026-09-12 00:08:24 +02:00
parent fb09048e45
commit 937c06ef8d
10 changed files with 102 additions and 28 deletions
+25 -7
View File
@@ -1,6 +1,6 @@
<template>
<div class="columns is-vcentered" style="height: 50rem;">
<div class="column is-2 is-offset-5">
<div class="column is-4 is-offset-4">
<form @submit.prevent="logIn">
<div class="field">
<label class="label">{{ t('login.username') }}</label>
@@ -25,29 +25,47 @@
</template>
<script setup>
import { ref } from 'vue';
import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { displayName, isLogedIn } from '../global';
import { useRouter } from 'vue-router';
const { t } = useI18n();
const route = useRouter();
onMounted(async () => {
console.log("HE");
const res = await fetch("/php/user/is_loged_in.php");
if (res.ok) {
const body = await res.json();
displayName.value = body.displayname;
isLogedIn.value = true;
route.push("/");
}
});
const userName = ref();
const password = ref();
async function logIn(){
async function logIn() {
const mes = {
"username": userName.value,
"pass": password.value
}
const res = await fetch("/php/user/ldapLogin.php", {
"body": mes,
"body": JSON.stringify(mes),
"method": "POST"
});
const body = await res.json();
isLogedIn.value = true;
displayName.value = body.displayname;
route.push("/");
if (res.ok) {
isLogedIn.value = true;
displayName.value = body.displayname;
route.push("/");
} else {
console.log(body.error);
isLogedIn.value = true;
}
}
</script>
+18
View File
@@ -0,0 +1,18 @@
<template>
</template>
<script setup>
import { onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { displayName, isLogedIn } from '../global';
const router = useRouter();
onMounted(async () => {
await fetch("/php/user/logout.php");
isLogedIn.value = false;
displayName.value = "";
router.push("/login");
});
</script>