35 lines
556 B
Vue
35 lines
556 B
Vue
<script setup lang="ts">
|
|
const { loggedIn, user, fetch: refreshSession } = useUserSession();
|
|
|
|
// create data model for the form
|
|
const credentials = reactive({
|
|
email: '',
|
|
password: '',
|
|
})
|
|
|
|
async function sendLogin() {
|
|
try {
|
|
await $fetch("/api/login", {
|
|
method: "POST",
|
|
body: credentials
|
|
})
|
|
|
|
await refreshSession()
|
|
await navigateTo('/dashboard') // user home page
|
|
|
|
} catch {
|
|
alert("Login failed.")
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<UContainer class="overflow-auto">
|
|
|
|
|
|
</UContainer>
|
|
</template>
|
|
|
|
<style scoped>
|
|
|
|
</style> |