fcakyon/claude-codex-settings / plugins/reusable-app-components/skills/app-auth
app-auth
VerifiedThis skill should be used when the user asks to build, design, add, refactor or fix "login", "auth", "authentication", "social login", "sign in", "signup", "password recovery", "remember last login", "switch accounts", or a "reusable login component", including Google, GitHub, Apple, Hugging Face and PocketBase auth. Use the shared login design, bundled SVG logos, same-tab social sign-in, remembered profiles and email forms, with framework-neutral TypeScript contracts, React components and a Vite demo. Native and TV flows remain integration contracts.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.2 KB |
| assets/AuthPanel.tsx | other | 728 B |
| assets/EmailAuth.tsx | other | 8.7 KB |
| assets/GoogleSignIn.tsx | other | 3.3 KB |
| assets/ProviderLogo.tsx | other | 551 B |
| assets/RememberedLogin.tsx | other | 1.5 KB |
| assets/SocialSignIn.tsx | other | 1.1 KB |
| assets/auth-panel.css | other | 3.1 KB |
| assets/auth.ts | script | 884 B |
| assets/email-auth.css | other | 2.9 KB |
| assets/fonts/InterVariable.woff2 | binary | 344.0 KB |
| assets/fonts/OFL.txt | markdown | 4.3 KB |
| assets/google-sign-in.css | other | 840 B |
| assets/login.ts | script | 847 B |
| assets/logos.d.ts | script | 68 B |
| assets/logos/apple.svg | other | 650 B |
| assets/logos/github.svg | other | 822 B |
| assets/logos/google.svg | other | 742 B |
| assets/logos/huggingface.svg | other | 4.5 KB |
| assets/pocketbase.ts | script | 719 B |
| assets/social-sign-in.css | other | 1.3 KB |
| references/backend-standard.md | markdown | 5.1 KB |
| references/integration.md | markdown | 20.3 KB |
| references/journeys.md | markdown | 4.8 KB |
| references/platforms.md | markdown | 7.1 KB |
| references/provenance.md | markdown | 4.1 KB |
assets/EmailAuth.tsx
View on GitHub"use client";
import {
useEffect,
useId,
useRef,
useState,
type FormEvent,
type ReactNode,
} from "react";
import "./email-auth.css";
import type { EmailAuthAdapter, EmailAuthPurpose as Purpose } from "./auth";
type Phase = "login" | "signup" | "forgot" | "verify" | "password";
type Failure = {
message: string;
reason?: "email-exists" | "verification-needed";
};
export type EmailAuthCopy = {
titles: Record<Phase, string>;
email: string;
password: string;
newPassword: string;
showPassword: string;
hidePassword: string;
login: string;
signup: string;
continue: string;
forgot: string;
sendCode: string;
resend: string;
savePassword: string;
changeEmail: string;
pending: string;
code: string;
codeSent: (email: string) => string;
};
export type { EmailAuthAdapter } from "./auth"
export function EmailAuth<User, Recovery>({
adapter,
copy,
terms,
social,
beforeSubmit,
initialMode = "login",
initialEmail = "",
minPasswordLength = 8,
onAuthenticated,
onFailure,
}: {
adapter: EmailAuthAdapter<User, Recovery>;
copy: EmailAuthCopy;
terms?: ReactNode;
social?: ReactNode;
beforeSubmit?: ReactNode;
initialMode?: "login" | "signup";
initialEmail?: string;
minPasswordLength?: number;
onAuthenticated: (user: User) => void;
onFailure: (error: unknown) => Failure;
}) {
const id = useId();
const [phase, setPhase] = useState<Phase>(initialMode);
const [purpose, setPurpose] = useState<Purpose>("signup");
const [email, setEmail] = useState(initialEmail);
const [password, setPassword] = useState("");
const [code, setCode] = useState("");
const [acceptedTerms, setAcceptedTerms] = useState(false);
const [visible, setVisible] = useState(false);
const [pending, setPending] = useState(false);
const [failure, setFailure] = useState<Failure | null>(null);
const recovery = useRef<Recovery>(null!);
const operation = useRef<AbortController | null>(null);
useEffect(() => () => operation.current?.abort(), []);
const move = (next: Phase) => {
setFailure(null);
setPassword("");
setCode("");
setVisible(false);
setPhase(next);
};
const perform = async (work: (signal: AbortSignal) => Promise<void>) => {
const controller = new AbortController();
operation.current = controller;
setPending(true);
setFailure(null);
try {
await work(controller.signal);
} catch (error) {
if (!controller.signal.aborted) setFailure(onFailure(error));
} finally {
if (!controller.signal.aborted) setPending(false);
}
};
const requestCode = (nextPurpose: Purpose) =>
perform(async (signal) => {
await adapter.sendCode({ email, purpose: nextPurpose }, signal);
if (signal.aborted) return;
setPurpose(nextPurpose);
move("verify");
});
const submit = (event: FormEvent) => {
event.preventDefault();
if (phase === "forgot") {
void requestCode("reset");
return;
}
void perform(async (signal) => {
if (phase === "login") {
const user = await adapter.login({ email, password }, signal);
if (!signal.aborted) onAuthenticated(user);
} else if (phase === "signup") {
await adapter.register({ email, password, acceptedTerms }, signal);
if (!signal.aborted) {
setPurpose("signup");
move("verify");
}
} else if (phase === "verify" && purpose === "reset") {
const verified = await adapter.verifyResetCode({ email, code }, signal);
if (!signal.aborted) {
recovery.current = verified;
move("password");
}
} else if (phase === "verify") {
const user = await adapter.verifyEmail({ email, code }, signal);
if (!signal.aborted) onAuthenticated(user);
} else {
const user = await adapter.resetPassword(
{ recovery: recovery.current, password },
signal,
);
if (!signal.aborted) onAuthenticated(user);
}
});
};
const passwordPhase =
phase === "login" || phase === "signup" || phase === "password";
return (
<form className="app-email-auth" onSubmit={submit} aria-busy={pending}>
<h3>{copy.titles[phase]}</h3>
{phase === "login" || phase === "signup" ? social : null}
<fieldset disabled={pending}>
{phase === "verify" || phase === "password" ? null : (
<label htmlFor={id + "-email"}>
{copy.email}
<input
id={id + "-email"}
name="email"
type="email"
autoComplete="email"
required
value={email}
onChange={(event) => {
setEmail(event.target.value);
setFailure(null);
}}
/>
</label>
)}
{passwordPhase ? (
<div className="app-email-auth__field">
<label htmlFor={id + "-password"}>
{phase === "password" ? copy.newPassword : copy.password}
</label>
<span className="app-email-auth__password">
<input
id={id + "-password"}
name="password"
type={visible ? "text" : "password"}
autoComplete={
phase === "login" ? "current-password" : "new-password"
}
minLength={phase === "login" ? undefined : minPasswordLength}
required
value={password}
onChange={(event) => setPassword(event.target.value)}
/>
<button
type="button"
aria-label={visible ? copy.hidePassword : copy.showPassword}
onClick={() => setVisible(!visible)}
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z" />
<circle cx="12" cy="12" r="3" />
{visible ? <path d="m3 3 18 18" /> : null}
</svg>
</button>
</span>
</div>
) : null}
{phase === "signup" && terms ? (
<label className="app-email-auth__terms">
<input
type="checkbox"
required
checked={acceptedTerms}
onChange={(event) => setAcceptedTerms(event.target.checked)}
/>
<span>{terms}</span>
</label>
) : null}
{phase === "verify" ? (
<>
<p>{copy.codeSent(email)}</p>
<label htmlFor={id + "-code"}>
{copy.code}
<input
id={id + "-code"}
name="code"
type="text"
inputMode="numeric"
autoComplete="one-time-code"
pattern="[0-9]{6}"
maxLength={6}
required
value={code}
onChange={(event) => {
setCode(event.target.value);
setFailure(null);
}}
/>
</label>
</>
) : null}
{failure ? <p role="alert">{failure.message}</p> : null}
{failure?.reason === "verification-needed" ? (
<button type="button" onClick={() => void requestCode("signup")}>
{copy.sendCode}
</button>
) : null}
{phase === "login" || phase === "signup" ? beforeSubmit : null}
<button className="app-email-auth__primary" type="submit">
{phase === "login"
? copy.login
: phase === "forgot"
? copy.sendCode
: phase === "password"
? copy.savePassword
: copy.continue}
</button>
<div className="app-email-auth__links">
{phase === "login" ? (
<>
<button type="button" onClick={() => move("forgot")}>
{copy.forgot}
</button>
<button type="button" onClick={() => move("signup")}>
{copy.signup}
</button>
</>
) : phase === "signup" || phase === "forgot" ? (
<button type="button" onClick={() => move("login")}>
{copy.login}
</button>
) : phase === "verify" ? (
<>
<button type="button" onClick={() => void requestCode(purpose)}>
{copy.resend}
</button>
<button
type="button"
onClick={() => move(purpose === "reset" ? "forgot" : "signup")}
>
{copy.changeEmail}
</button>
</>
) : null}
</div>
</fieldset>
{pending ? <p role="status">{copy.pending}</p> : null}
</form>
);
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |