fix login and create logout

fix login to login by email password
This commit is contained in:
NekoVari 2023-11-18 18:06:27 +07:00
parent 19b4d18941
commit 48e29ee9fd
3 changed files with 795 additions and 7 deletions

View file

@ -55,7 +55,7 @@
</v-list-item>
</v-list>
<v-btn class = "ma-2 mt-3" width="100%"
<v-btn @click.prevent="logout" class = "ma-2 mt-3" width="100%"
color="red">
ลงชอออก
</v-btn>
@ -69,6 +69,8 @@
<script setup>
import {RouterLink} from 'vue-router';
import { VContainer } from 'vuetify/lib/components/index.mjs';
import router from '@/plugins/router'
const account_items = [
{ text: 'ตั้งค่าบัญชี',
@ -90,5 +92,17 @@ const display_items = [
icon: 'mdi-chevron-right',}
]
function logout() {
if (sessionStorage.getItem('current_user')){
console.log('loging out...');
fetch(`https://little-lines-backend.techtransthai.org/api/users/logout`, {
method: "GET"
}).then(()=>{
console.log('loged out');
sessionStorage.removeItem('current_user');
router.push({ name: 'home' });
})
}
}
</script>