Login Done
This commit is contained in:
@@ -51,5 +51,6 @@ const items = [
|
||||
// { label: 'Reports', icon: 'fa-chart-line', to: '/reports' },
|
||||
{ label: 'menu.userSettings', icon: 'fa-user-gear', to: '/user_settings' },
|
||||
{ label: 'menu.settings', icon: 'fa-gear', to: '/settings' },
|
||||
{ label: 'menu.logout', icon: 'fa-right-from-bracket', to: '/logout' },
|
||||
];
|
||||
</script>
|
||||
|
||||
+8
-7
@@ -1,17 +1,18 @@
|
||||
{
|
||||
"userSettings":{
|
||||
"userSettings": {
|
||||
"themeSelect": "Select theme",
|
||||
"light":"Light",
|
||||
"dark":"Dark"
|
||||
"light": "Light",
|
||||
"dark": "Dark"
|
||||
},
|
||||
"menu": {
|
||||
"settings": "Settings",
|
||||
"userSettings": "User settings",
|
||||
"dashboard": "Dashboard"
|
||||
"dashboard": "Dashboard",
|
||||
"logout": "Logout"
|
||||
},
|
||||
"settings":{
|
||||
"users":"Users",
|
||||
"groups":"Groups"
|
||||
"settings": {
|
||||
"users": "Users",
|
||||
"groups": "Groups"
|
||||
},
|
||||
"common": {
|
||||
"save": "Save",
|
||||
|
||||
+2
-1
@@ -7,7 +7,8 @@
|
||||
"menu": {
|
||||
"settings": "Nastavitve",
|
||||
"userSettings": "Uporabniške nastavitve",
|
||||
"dashboard": "Nadzorna plošča"
|
||||
"dashboard": "Nadzorna plošča",
|
||||
"logout": "Odjava"
|
||||
},
|
||||
"settings": {
|
||||
"users": "Uporabni",
|
||||
|
||||
+25
-7
@@ -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>
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user