uploading files and a lot more
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
<script setup>
|
||||
console.log(useCookie("sessionToken").value)
|
||||
<script lang="ts" setup>
|
||||
import type { User } from '~/types/user';
|
||||
const { fetchUser } = useUser()
|
||||
|
||||
if (useCookie("sessionToken").value) {
|
||||
await navigateTo('/')
|
||||
}
|
||||
definePageMeta({
|
||||
middleware: "unauth"
|
||||
});
|
||||
|
||||
let username_or_email = ref('')
|
||||
let password = ref('')
|
||||
@@ -11,7 +12,7 @@ let password = ref('')
|
||||
let error = ref('')
|
||||
|
||||
const submitForm = async () => {
|
||||
let response = await useFetch('/api/login', {
|
||||
let response = await useFetch<User>('/api/login', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
"username_or_email": username_or_email.value,
|
||||
@@ -24,15 +25,15 @@ const submitForm = async () => {
|
||||
error.value = response.error.value.data.message
|
||||
setTimeout(() => error.value = "", 15000)
|
||||
} else {
|
||||
await navigateTo('/')
|
||||
await fetchUser()
|
||||
await navigateTo('/home')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-screen min-w-screen grid place-content-center bg-base">
|
||||
<div
|
||||
class="flex flex-col text-center bg-surface border border-muted/20 shadow-md px-10 py-8 rounded-2xl min-w-0 max-w-[313px]">
|
||||
<div class="flex flex-col text-center bg-surface border shadow-md px-10 py-8 rounded-2xl min-w-0 max-w-[313px]">
|
||||
<h2 class="font-semibold text-2xl mb-2">Login</h2>
|
||||
<Input v-model="username_or_email" placeholder="Username or Email..." />
|
||||
<Input v-model="password" type="password" placeholder="Password..." />
|
||||
|
||||
Reference in New Issue
Block a user