Login · Masuk

Sign in with email or phone number and password, behind Cloudflare Turnstile. No shell.

$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/screen-login.json
Buka layar penuh

When to use

  • The sign-in page of the app (/login), for every role: "Email atau nomor HP" + password, behind Cloudflare Turnstile when the server has a sitekey.
  • Accounts come only by invite (Undangan · Buat password). There is no sign-up and no reset flow.

When not to use

  • First password after an invite → Undangan (the link from email or WhatsApp).
  • A forgotten password → the person asks HR ("Lupa password? Hubungi HR."); HR sends a new invite ("Atur ulang password" on Karyawan · Detail · Akun login).

Built from

Usage

The screen is the page content only. Put it inside AppShell (once, in your layout) and pass your data.

page.tsx
import { Login } from "@/components/screens/login/login"import { Logo } from "@/components/brand/logo"export default function Page() {  const setup = useSetupStatus() // GET /api/setup/status → { company, turnstile_sitekey }  const login = useLogin() // POST /api/auth/login { identifier, password, cf-turnstile-response }  const turnstile = useTurnstile(setup.turnstile_sitekey) // the real widget; reset after every failed attempt  return (    <Login      company={setup.company}      logo={<Logo />}      turnstile={setup.turnstile_sitekey ? turnstile.widget : undefined}      status={login.pending ? "submitting" : "idle"}      error={login.error} // { kind: "credentials" | "inactive" | "turnstile" | "turnstile-pending" | "rate-limit" | "network" }      attempt={login.failures} // +1 on every failed answer: shake + focus      onSubmit={(v) => (turnstile.token ? login.run({ ...v, token: turnstile.token }) : login.fail({ kind: "turnstile-pending" }))}    />  )}

Installation

Adds the screen, its parts and its types. The components it uses come with it (registry dependencies).

terminal
bunx --bun shadcn@latest add https://mahrdesign.faizintifada.com/r/screen-login.json

API

import { Login } from "@/components/screens/login/login"
PropTypeDefaultDescription
companystring–The line under "Masuk ke MaHR". Left out on the first run (no company yet).
logoReactNode–The brand mark at the top of the card (48; 40 on a phone).
turnstileReactNode–The Cloudflare Turnstile slot (the real widget; 65 high while it loads). Leave it out when the server sends no sitekey.
status"idle" | "submitting""idle""Masuk" → "Masuk…" (the button keeps its width; a second Enter is ignored).
errorLoginError | null–The answer of the last attempt; the screen owns the sentence. credentials (both fields red) · inactive · rate-limit (warning) · turnstile · turnstile-pending · network (danger).
attemptnumber0+1 on every failed answer: replays the shake; credentials → focus in Password.
onSubmit({ identifier, password }) => void–Called only when both fields pass. identifier is normalised: an email lower-case, a phone number as 0812… digits (+62 / 62 → 0).
defaultValues{ identifier?, password? }–Start values; the form keeps its own values.
autoFocusbooleantrueFocus "Email atau nomor HP" on load, pointer devices only (a phone keyboard would cover the page).
minHeightnumber | string100dvhThe gallery passes 900 (an iframe would copy a dvh height).