CI & Build / Python lint (push) Successful in 4s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / TypeScript typecheck (push) Successful in 42s
CI & Build / integration (push) Successful in 1m39s
CI & Build / Python tests (push) Successful in 2m4s
CI & Build / Build & push image (push) Canceled after 0s
The five auth views each defined .btn-submit identically — full-width, filled, 0.6rem — and LoginView additionally defined .btn-oauth. Those rules are now gone entirely rather than tokenised: the template composes `btn-primary btn-block` and `btn-ghost btn-block`, and there is nothing left per-file to drift. That is the difference between this and the earlier chunks. Consolidating the core four moved geometry into one place but left every semantic name defining its own; this removes the definition. Two variants added, both earned rather than invented: - .btn-text — no fill, no border. The most common shape in the dense surfaces (dismiss, cancel-beside-confirm, clear-search) where a border would draw a box around something that should read as an action on the adjacent text. Distinct from ghost, which IS a box. - .btn-danger-outline — already existed independently in three views before this sheet, which is what makes it a variant and not a one-off. It is what a delete looks like when it must not shout. .btn-block composes with a variant rather than being one, because width is orthogonal to appearance. Also corrected the sheet's own header, which claimed "no template changes" — true when it was written, false as of this commit. It now states the actual model: a button is variant + size, composed in the template. Semantic per-view names are named as the thing that drifted, and why: a name says what a button is FOR and nothing about what it should look like, so two buttons doing the same job in two views had no reason to match, and didn't. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UaYUaouG9jjhATyuxCKrQs
214 lines
4.8 KiB
Vue
214 lines
4.8 KiB
Vue
<script setup lang="ts">
|
|
import { ref, computed, onMounted } from "vue";
|
|
import { useRouter, useRoute } from "vue-router";
|
|
import { useAuthStore } from "@/stores/auth";
|
|
import AppLogo from "@/components/AppLogo.vue";
|
|
|
|
const router = useRouter();
|
|
const route = useRoute();
|
|
const authStore = useAuthStore();
|
|
|
|
const username = ref("");
|
|
const password = ref("");
|
|
const error = ref("");
|
|
const submitting = ref(false);
|
|
|
|
const oauthError = computed(() => route.query.error === "oauth");
|
|
|
|
onMounted(async () => {
|
|
await authStore.checkHasUsers();
|
|
if (oauthError.value) {
|
|
error.value = "SSO login failed. Please try again.";
|
|
}
|
|
});
|
|
|
|
async function handleSubmit() {
|
|
error.value = "";
|
|
submitting.value = true;
|
|
try {
|
|
await authStore.login(username.value, password.value);
|
|
const redirect = (route.query.redirect as string) || "/";
|
|
router.push(redirect);
|
|
} catch (e: unknown) {
|
|
if (e && typeof e === "object" && "body" in e) {
|
|
const body = (e as { body?: { error?: string } }).body;
|
|
error.value = body?.error || "Login failed";
|
|
} else {
|
|
error.value = "Login failed";
|
|
}
|
|
} finally {
|
|
submitting.value = false;
|
|
}
|
|
}
|
|
|
|
function loginWithOAuth() {
|
|
window.location.href = "/api/auth/oauth/login";
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<main class="auth-page">
|
|
<div class="auth-card">
|
|
<div class="auth-brand"><AppLogo :size="32" /><h1>Sign In</h1></div>
|
|
<p v-if="!authStore.hasUsers" class="auth-hint">
|
|
No accounts yet.
|
|
<router-link to="/register">Create the first account</router-link>
|
|
to get started.
|
|
</p>
|
|
|
|
<p v-if="error" class="error-msg">{{ error }}</p>
|
|
|
|
<form v-if="authStore.localAuthEnabled" @submit.prevent="handleSubmit">
|
|
<div class="field">
|
|
<label for="username">Username</label>
|
|
<input
|
|
id="username"
|
|
v-model="username"
|
|
type="text"
|
|
autocomplete="username"
|
|
required
|
|
class="input"
|
|
/>
|
|
</div>
|
|
<div class="field">
|
|
<label for="password">Password</label>
|
|
<input
|
|
id="password"
|
|
v-model="password"
|
|
type="password"
|
|
autocomplete="current-password"
|
|
required
|
|
class="input"
|
|
/>
|
|
</div>
|
|
<p class="forgot-link">
|
|
<router-link to="/forgot-password">Forgot your password?</router-link>
|
|
</p>
|
|
<button type="submit" class="btn-primary btn-block" :disabled="submitting">
|
|
{{ submitting ? "Signing in..." : "Sign In" }}
|
|
</button>
|
|
</form>
|
|
|
|
<div
|
|
v-if="authStore.localAuthEnabled && authStore.oauthEnabled"
|
|
class="divider"
|
|
>
|
|
<span>or</span>
|
|
</div>
|
|
|
|
<button
|
|
v-if="authStore.oauthEnabled"
|
|
class="btn-ghost btn-block"
|
|
@click="loginWithOAuth"
|
|
>
|
|
Login with Authentik
|
|
</button>
|
|
|
|
<p v-if="authStore.localAuthEnabled" class="auth-footer">
|
|
Don't have an account?
|
|
<router-link to="/register">Register</router-link>
|
|
</p>
|
|
</div>
|
|
</main>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.auth-page {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-height: 100vh;
|
|
padding: 1rem;
|
|
}
|
|
.auth-card {
|
|
width: 100%;
|
|
max-width: 400px;
|
|
background: var(--color-bg-card);
|
|
border: 1px solid var(--color-border);
|
|
border-radius: var(--radius-md);
|
|
padding: 2rem;
|
|
}
|
|
.auth-brand {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 0.5rem;
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
.auth-card h1 {
|
|
margin: 0;
|
|
text-align: center;
|
|
}
|
|
.auth-hint {
|
|
text-align: center;
|
|
font-size: 0.9rem;
|
|
color: var(--color-text-secondary);
|
|
margin-bottom: 1rem;
|
|
}
|
|
.auth-hint a {
|
|
color: var(--color-primary);
|
|
}
|
|
.field {
|
|
margin-bottom: 1rem;
|
|
}
|
|
.field label {
|
|
display: block;
|
|
font-size: 0.9rem;
|
|
font-weight: 600;
|
|
margin-bottom: 0.35rem;
|
|
}
|
|
.input {
|
|
width: 100%;
|
|
padding: 0.5rem 0.75rem;
|
|
border: 1px solid var(--color-border);
|
|
border-radius: var(--radius-sm);
|
|
font-size: 0.95rem;
|
|
background: var(--color-bg);
|
|
color: var(--color-text);
|
|
box-sizing: border-box;
|
|
}
|
|
.input:focus {
|
|
outline: none;
|
|
border-color: var(--color-primary);
|
|
}
|
|
.error-msg {
|
|
color: var(--color-danger);
|
|
font-size: 0.9rem;
|
|
margin: 0 0 0.75rem;
|
|
}
|
|
.divider {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.75rem;
|
|
margin: 1.25rem 0;
|
|
color: var(--color-text-secondary);
|
|
font-size: 0.85rem;
|
|
}
|
|
.divider::before,
|
|
.divider::after {
|
|
content: "";
|
|
flex: 1;
|
|
border-top: 1px solid var(--color-border);
|
|
}
|
|
.auth-footer {
|
|
text-align: center;
|
|
font-size: 0.9rem;
|
|
color: var(--color-text-secondary);
|
|
margin: 1rem 0 0;
|
|
}
|
|
.auth-footer a {
|
|
color: var(--color-primary);
|
|
}
|
|
.forgot-link {
|
|
text-align: right;
|
|
margin: -0.5rem 0 0.75rem;
|
|
font-size: 0.85rem;
|
|
}
|
|
.forgot-link a {
|
|
color: var(--color-text-secondary);
|
|
}
|
|
.forgot-link a:hover {
|
|
color: var(--color-primary);
|
|
}
|
|
</style>
|