Files
petvity/components/auth/OrangecatButton.tsx
T
CatoandClaude Opus 5.5 2b7a71cb4f feat(auth): sign in with OrangeCat (#104)
"Sign in with OrangeCat" (OIDC) is now the primary action on /login and
/register; email + password stays behind a disclosure so existing accounts
are not locked out. OrangeCat's own page carries Google, GitHub, email and
open registration.

- Provider: client_secret_post + PKCE + state, scope "openid profile email",
  issuer https://orangecat.ch (ORANGECAT_OAUTH_ISSUER overrides). Absent,
  not broken, until ORANGECAT_OAUTH_CLIENT_ID/SECRET are set.
- Users are keyed ONLY on the new users.orangecat_sub (additive migration
  0007). The provider profile carries no email, so Auth.js never looks a
  user up by email; a new sub always creates a new user. A taken email gets
  an undeliverable @users.invalid placeholder.
- An OrangeCat login never earns ADMIN_EMAILS promotion (email unverified).
- Identity only: no OrangeCat token refresh, tokens not stored.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 05:01:17 -07:00

38 lines
932 B
TypeScript

"use client";
import { useState } from "react";
import { signIn } from "next-auth/react";
/**
* The primary way into petvity: OrangeCat's own sign-in page offers Google,
* GitHub, email + password, an emailed code and open registration, so one
* button carries all of them.
*/
export function OrangecatButton({
label,
hint,
redirectTo,
}: {
label: string;
hint?: string;
redirectTo: string;
}) {
const [pending, setPending] = useState(false);
return (
<div>
<button
type="button"
disabled={pending}
onClick={() => {
setPending(true);
void signIn("orangecat", { redirectTo });
}}
className="btn-primary w-full justify-center py-3 text-base disabled:opacity-60"
>
{pending ? "Opening OrangeCat…" : label}
</button>
{hint && <p className="mt-2 text-center text-xs text-[var(--muted)]">{hint}</p>}
</div>
);
}