Files
WRNexusJS/packages/auth/components/SignIn.wrn
T
Clintchiz b1086d14e9
Quality / quality (ubuntu-latest) (push) Failing after 6m7s
Quality / quality (windows-latest) (push) Canceled after 0s
fix(auth): secure hydration and align password forms
2026-08-11 17:05:04 +05:30

68 lines
3.3 KiB
Plaintext

import PasskeyButton from "./PasskeyButton.wrn"
import { Button, Checkbox, Input, TogglePassword } from "@wrnexus/ui"
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"
identifierPlaceholder = "Enter your email, mobile number, or username"
passwordLabel = "Password"
passwordPlaceholder = "Enter your 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="" />
<Input id="auth-sign-in-identifier" name="identifier" type="text" label="{identifierLabel}" autocomplete="username webauthn" placeholder="{identifierPlaceholder}" icon="icon-[lucide--at-sign]" color="{color}" size="{size}" />
<div class="space-y-1.5">
<TogglePassword
label="{passwordLabel}"
cornerHint="Forgot password?"
cornerHref="{forgotHref}"
name="password"
placeholder="{passwordPlaceholder}"
autocomplete="current-password"
pattern=""
color="{color}"
size="{size}"
/>
</div>
{#if showRemember}
<Checkbox id="auth-sign-in-remember" name="rememberDevice" label="Trust this device" color="{color}" size="{size}" />
{/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" label="{submitLabel}" variant="solid" color="{color}" size="{size}" fullWidth="true" />
</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>
}
}