Files
hnh-map/frontend-nuxt/pages/login.vue
Nikolay Tatarinov 6529d7370e Add configuration files and update project documentation
- Introduced .editorconfig for consistent coding styles across the project.
- Added .golangci.yml for Go linting configuration.
- Updated AGENTS.md to clarify project structure and components.
- Enhanced CONTRIBUTING.md with Makefile usage for common tasks.
- Updated Dockerfiles to use Go 1.24 and improved build instructions.
- Refined README.md and deployment documentation for clarity.
- Added testing documentation in testing.md for backend and frontend tests.
- Introduced Makefile for streamlined development commands and tasks.
2026-03-01 01:51:47 +03:00

79 lines
2.6 KiB
Vue

<template>
<div class="min-h-screen flex flex-col items-center justify-center bg-gradient-to-br from-base-200 via-base-300 to-primary/10 p-4 overflow-hidden">
<div class="card w-full max-w-sm bg-base-100 shadow-2xl ring-1 ring-base-300 login-card">
<div class="card-body">
<h1 class="card-title justify-center text-2xl">HnH Map</h1>
<p class="text-center text-base-content/70 text-sm">Log in to continue</p>
<div v-if="(oauthProviders ?? []).length" class="flex flex-col gap-2">
<a
v-for="p in (oauthProviders ?? [])"
:key="p"
:href="api.oauthLoginUrl(p, redirect || undefined)"
class="btn btn-outline gap-2"
>
<span v-if="p === 'google'">Login with Google</span>
<span v-else>Login with {{ p }}</span>
</a>
<div class="divider text-sm">or</div>
</div>
<form @submit.prevent="submit" class="flex flex-col gap-4">
<fieldset class="fieldset">
<label class="label" for="user">User</label>
<input
id="user"
v-model="user"
type="text"
class="input"
required
autocomplete="username"
/>
</fieldset>
<PasswordInput
v-model="pass"
label="Password"
required
autocomplete="current-password"
/>
<p v-if="error" class="text-error text-sm">{{ error }}</p>
<button type="submit" class="btn btn-primary transition-all duration-200 hover:scale-[1.02]" :disabled="loading">
<span v-if="loading" class="loading loading-spinner loading-sm" />
<span v-else>Log in</span>
</button>
</form>
</div>
</div>
</div>
</template>
<script setup lang="ts">
// No auth required; auth.global skips this path
const user = ref('')
const pass = ref('')
const error = ref('')
const loading = ref(false)
const oauthProviders = ref<string[]>([])
const router = useRouter()
const route = useRoute()
const api = useMapApi()
const redirect = computed(() => (route.query.redirect as string) || '')
onMounted(async () => {
oauthProviders.value = await api.oauthProviders()
})
async function submit() {
error.value = ''
loading.value = true
try {
await api.login(user.value, pass.value)
await router.push(redirect.value || '/profile')
} catch (e: unknown) {
error.value = e instanceof Error ? e.message : 'Login failed'
} finally {
loading.value = false
}
}
</script>