59 lines
4.3 KiB
Plaintext
59 lines
4.3 KiB
Plaintext
component SignIn {
|
|
props {
|
|
action = "/api/auth/login"
|
|
schema = "auth-login"
|
|
returnTo = "/"
|
|
redirect = ""
|
|
mfaHref = "/two-factor"
|
|
title = "Welcome back"
|
|
description = "Sign in to continue to your account."
|
|
identifierLabel = "Email, phone, or username"
|
|
passwordLabel = "Password"
|
|
submitLabel = "Sign in"
|
|
forgotHref = "/recover"
|
|
signUpHref = "/sign-up"
|
|
showRemember = true
|
|
showPasskey = true
|
|
showSignUp = true
|
|
color = "primary"
|
|
size = "md"
|
|
class = ""
|
|
}
|
|
view {
|
|
<section {...attrs} data-wrnexus-runtime="auth" data-auth-sign-in data-mfa-href='{mfaHref}' class='w-full max-w-md rounded-[var(--wire-radius-lg)] border border-[var(--wire-color-border)] bg-[var(--wire-color-surface)] p-6 text-[var(--wire-color-text)] shadow-[var(--wire-shadow-2)] {class}'>
|
|
<header class="mb-6 space-y-1.5">
|
|
<h1 class="m-0 text-2xl font-semibold tracking-tight">{title}</h1>
|
|
<p class="m-0 text-sm text-[var(--wire-color-muted)]">{description}</p>
|
|
</header>
|
|
<form method="post" action='{action}' data-schema='{schema}' data-redirect='{redirect}' novalidate class="space-y-4">
|
|
<input type="hidden" name="returnTo" value='{returnTo}' />
|
|
<input type="hidden" name="deviceFingerprint" value="" />
|
|
<input type="hidden" name="deviceName" value="" />
|
|
<div class="space-y-1.5">
|
|
<label for="auth-sign-in-identifier" class="block text-sm font-medium">{identifierLabel}</label>
|
|
<input id="auth-sign-in-identifier" name="identifier" type="text" autocomplete="username webauthn" aria-describedby="auth-sign-in-identifier-error" class="h-11 w-full rounded-[var(--wire-radius-sm)] border border-[var(--wire-color-border)] bg-[var(--wire-color-surface-2)] px-3 text-sm outline-none focus:border-[var(--wire-color-primary)] focus:ring-2 focus:ring-[color-mix(in_srgb,var(--wire-color-primary)_25%,transparent)]" />
|
|
<p id="auth-sign-in-identifier-error" data-error="identifier" class="m-0 min-h-4 text-xs text-[var(--wire-color-danger)]"></p>
|
|
</div>
|
|
<div class="space-y-1.5">
|
|
<div class="flex items-center justify-between gap-3 text-sm font-medium"><label for="auth-sign-in-password">{passwordLabel}</label><a href='{forgotHref}' class="text-xs text-[var(--wire-color-primary)] hover:underline">Forgot password?</a></div>
|
|
<input id="auth-sign-in-password" name="password" type="password" autocomplete="current-password" aria-describedby="auth-sign-in-password-error" class="h-11 w-full rounded-[var(--wire-radius-sm)] border border-[var(--wire-color-border)] bg-[var(--wire-color-surface-2)] px-3 text-sm outline-none focus:border-[var(--wire-color-primary)] focus:ring-2 focus:ring-[color-mix(in_srgb,var(--wire-color-primary)_25%,transparent)]" />
|
|
<p id="auth-sign-in-password-error" data-error="password" class="m-0 min-h-4 text-xs text-[var(--wire-color-danger)]"></p>
|
|
</div>
|
|
{#if showRemember}
|
|
<label class="flex items-center gap-2 text-sm text-[var(--wire-color-muted)]"><input name="rememberDevice" type="checkbox" class="size-4 rounded border-[var(--wire-color-border)]" />Trust this device</label>
|
|
{/if}
|
|
<slot></slot>
|
|
<p data-error="_form" role="alert" class="m-0 hidden rounded-[var(--wire-radius-sm)] bg-[color-mix(in_srgb,var(--wire-color-danger)_10%,transparent)] p-3 text-sm text-[var(--wire-color-danger)]"></p>
|
|
<button type="submit" class="inline-flex h-11 w-full items-center justify-center rounded-[var(--wire-radius-sm)] bg-[var(--wire-color-primary)] px-4 text-sm font-semibold text-white transition-opacity hover:opacity-90 disabled:cursor-wait disabled:opacity-60">{submitLabel}</button>
|
|
</form>
|
|
{#if showPasskey}
|
|
<div class="my-4 flex items-center gap-3 text-xs text-[var(--wire-color-muted)]"><span class="h-px flex-1 bg-[var(--wire-color-border)]"></span><span>or</span><span class="h-px flex-1 bg-[var(--wire-color-border)]"></span></div>
|
|
<PasskeyButton mode="authenticate" identifier="" mfaHref='{mfaHref}' fullWidth="true" />
|
|
{/if}
|
|
{#if showSignUp}
|
|
<p class="mb-0 mt-5 text-center text-sm text-[var(--wire-color-muted)]">New here? <a href='{signUpHref}' class="font-semibold text-[var(--wire-color-primary)] hover:underline">Create an account</a></p>
|
|
{/if}
|
|
</section>
|
|
}
|
|
}
|