This is an automated email from the ASF dual-hosted git repository. lahirujayathilake pushed a commit to branch auth-endpoints-web in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
commit 70ceec384d7fb46381d1a985bb481e69daa849c8 Author: lahiruj <[email protected]> AuthorDate: Wed Jun 17 00:32:06 2026 -0400 Reduce sign-in to a single OIDC button --- web/src/app/(auth)/sign-in/SignInForm.tsx | 64 +++---------------------------- web/src/app/(auth)/sign-in/page.tsx | 6 +-- 2 files changed, 7 insertions(+), 63 deletions(-) diff --git a/web/src/app/(auth)/sign-in/SignInForm.tsx b/web/src/app/(auth)/sign-in/SignInForm.tsx index 9fbc4aa2c..aa4c30188 100644 --- a/web/src/app/(auth)/sign-in/SignInForm.tsx +++ b/web/src/app/(auth)/sign-in/SignInForm.tsx @@ -1,77 +1,23 @@ "use client"; import { Button } from "@/shared/ui/button"; -import { Label } from "@/shared/ui/label"; import { signIn } from "next-auth/react"; import { useSearchParams } from "next/navigation"; import { useState } from "react"; -type Mode = "dev" | "oidc"; -type Level = "viewer" | "manager" | "admin"; - -const LEVELS: Array<{ id: Level; label: string; hint: string }> = [ - { id: "viewer", label: "Viewer", hint: "Read-only (hpc:read)" }, - { id: "manager", label: "Manager", hint: "hpc:read/write, amie:read" }, - { id: "admin", label: "Admin", hint: "All privileges" }, -]; - -export function SignInForm({ mode }: { mode: Mode }) { +export function SignInForm() { const params = useSearchParams(); const callbackUrl = params.get("callbackUrl") ?? "/"; - const [level, setLevel] = useState<Level>("admin"); const [submitting, setSubmitting] = useState(false); - const [error, setError] = useState<string | null>(null); - - const submitDev = async () => { - setSubmitting(true); - setError(null); - const res = await signIn("credentials", { - level, - redirect: false, - callbackUrl, - }); - setSubmitting(false); - if (!res || res.error) { - setError(res?.error ?? "Sign in failed"); - return; - } - window.location.assign(res.url ?? callbackUrl); - }; - const submitOidc = async () => { + const onSubmit = async () => { setSubmitting(true); await signIn("oidc", { callbackUrl }); }; - if (mode === "oidc") { - return ( - <Button onClick={submitOidc} disabled={submitting} className="w-full"> - Sign in with Custos - </Button> - ); - } - return ( - <div className="flex flex-col gap-4"> - <div className="flex flex-col gap-2"> - <Label htmlFor="dev-level">Dev privilege level</Label> - <select - id="dev-level" - value={level} - onChange={(e) => setLevel(e.target.value as Level)} - className="h-10 rounded-md border border-input bg-background px-3 text-sm" - > - {LEVELS.map((l) => ( - <option key={l.id} value={l.id}> - {l.label} — {l.hint} - </option> - ))} - </select> - </div> - <Button onClick={submitDev} disabled={submitting} className="w-full"> - Sign in - </Button> - {error && <p className="text-sm text-destructive">{error}</p>} - </div> + <Button onClick={onSubmit} disabled={submitting} className="w-full"> + Sign in + </Button> ); } diff --git a/web/src/app/(auth)/sign-in/page.tsx b/web/src/app/(auth)/sign-in/page.tsx index 2e5d4b1b9..1228652bf 100644 --- a/web/src/app/(auth)/sign-in/page.tsx +++ b/web/src/app/(auth)/sign-in/page.tsx @@ -1,5 +1,4 @@ import { Suspense } from "react"; -import { serverEnv } from "@/lib/env"; import { SignInForm } from "./SignInForm"; export const metadata = { @@ -7,7 +6,6 @@ export const metadata = { }; export default function SignInPage() { - const mode = serverEnv.PORTAL_AUTH_MODE; return ( <div className="flex min-h-screen items-center justify-center bg-muted px-6 py-12"> <div className="w-full max-w-md rounded-2xl border border-border bg-card p-8 shadow-sm"> @@ -17,11 +15,11 @@ export default function SignInPage() { </span> <h1 className="text-xl font-semibold tracking-tight">Sign in</h1> <p className="text-sm text-muted-foreground"> - {mode === "oidc" ? "Sign in with your Custos account." : "Pick a dev privilege level."} + Sign in with your Custos account. </p> </div> <Suspense fallback={null}> - <SignInForm mode={mode} /> + <SignInForm /> </Suspense> </div> </div>
