- Upgrade to Nuxt 4 (sources under app/), add @nuxt/ui, Tailwind v4 and Lucide icons; drop @nuxtjs/tailwindcss - Replace the custom Yale* components, Modal, Navbar and icon components with UButton/UInput/UModal/UTable/UCard/UHeader/UBadge/UAlert and toasts - Add dark/light mode toggle and a logout button - Add a useApi composable: central base URL/credentials, JSON-encoded bodies, error handling, and redirect to login when the session expires - Fix modal listener leak, missing People heading, unhandled fetch errors and login redirect for already-authenticated users - Make the code and people tables fit on phone screens - Retake README screenshots
62 lines
1.7 KiB
Vue
62 lines
1.7 KiB
Vue
<script setup lang="ts">
|
|
const api = useApi()
|
|
const authenticated = useCookie<boolean>('authenticated')
|
|
|
|
const password = ref('')
|
|
const showPassword = ref(false)
|
|
const error = ref('')
|
|
const loading = ref(false)
|
|
|
|
const handleLogin = async () => {
|
|
error.value = ''
|
|
loading.value = true
|
|
|
|
const response = await api.post<boolean>('/api/Authentication/login', password.value)
|
|
loading.value = false
|
|
|
|
if (response.success) {
|
|
authenticated.value = true
|
|
await navigateTo('/')
|
|
} else {
|
|
error.value = response.error ?? 'Unknown error'
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<UCard class="w-full md:w-96">
|
|
<template #header>
|
|
<div class="text-center">
|
|
<h1 class="text-5xl font-bold">Yale</h1>
|
|
<p class="text-muted mt-1">User Access</p>
|
|
</div>
|
|
</template>
|
|
|
|
<UForm :state="{ password }" class="space-y-4" @submit="handleLogin">
|
|
<UFormField name="password" :error="error || undefined">
|
|
<UInput
|
|
v-model="password"
|
|
:type="showPassword ? 'text' : 'password'"
|
|
placeholder="Password"
|
|
autocomplete="current-password"
|
|
class="w-full"
|
|
autofocus
|
|
>
|
|
<template #trailing>
|
|
<UButton
|
|
color="neutral"
|
|
variant="link"
|
|
size="sm"
|
|
:icon="showPassword ? 'i-lucide-eye-off' : 'i-lucide-eye'"
|
|
:aria-label="showPassword ? 'Hide password' : 'Show password'"
|
|
@click="showPassword = !showPassword"
|
|
/>
|
|
</template>
|
|
</UInput>
|
|
</UFormField>
|
|
|
|
<UButton type="submit" block :loading="loading" :disabled="!password">Login</UButton>
|
|
</UForm>
|
|
</UCard>
|
|
</template>
|