feat: establish ZITADEL OIDC account portal foundation
This commit is contained in:
1 parent
4404849fc4
commit
40af500750
28 files changed
+898
-10
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import Link from "next/link";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
export function AccountCard({
|
||||
title,
|
||||
description,
|
||||
href,
|
||||
action
|
||||
}: {
|
||||
title: string;
|
||||
description: ReactNode;
|
||||
href: string;
|
||||
action: string;
|
||||
}) {
|
||||
return (
|
||||
<article className="card action-card">
|
||||
<h2>{title}</h2>
|
||||
<p className="muted">{description}</p>
|
||||
<Link className="button button-outline" href={href}>{action}</Link>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
export function DataRow({
|
||||
label,
|
||||
value
|
||||
}: {
|
||||
label: string;
|
||||
value?: string | null;
|
||||
}) {
|
||||
return (
|
||||
<div className="data-row">
|
||||
<dt>{label}</dt>
|
||||
<dd>{value || "Not provided"}</dd>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import Link from "next/link";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import { signOut } from "@/auth";
|
||||
|
||||
type AccountUser = {
|
||||
id: string;
|
||||
name?: string | null;
|
||||
email?: string | null;
|
||||
image?: string | null;
|
||||
};
|
||||
|
||||
const navigation = [
|
||||
{ href: "/account", label: "Overview", description: "Account home" },
|
||||
{ href: "/account/profile", label: "Profile", description: "Personal information" },
|
||||
{ href: "/account/security", label: "Security", description: "Credentials and access" }
|
||||
] as const;
|
||||
|
||||
export function AccountShell({
|
||||
user,
|
||||
children
|
||||
}: {
|
||||
user: AccountUser;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
async function portalLogout() {
|
||||
"use server";
|
||||
await signOut({ redirectTo: "/signin" });
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="app-layout">
|
||||
<aside className="sidebar">
|
||||
<Link href="/account" className="brand" aria-label="ZitPlane account home">
|
||||
<span className="brand-symbol" aria-hidden="true">Z</span>
|
||||
<span className="brand-label">
|
||||
<strong>ZitPlane</strong>
|
||||
<small>Account Center</small>
|
||||
</span>
|
||||
</Link>
|
||||
<p className="nav-heading">ACCOUNT</p>
|
||||
<nav aria-label="Account navigation" className="nav-list">
|
||||
{navigation.map((item) => (
|
||||
<Link key={item.href} href={item.href} className="nav-item">
|
||||
<span>{item.label}</span>
|
||||
<small>{item.description}</small>
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
<div className="sidebar-spacer" />
|
||||
<div className="identity-tile">
|
||||
<div className="avatar" aria-hidden="true">
|
||||
{(user.name ?? user.email ?? "U").charAt(0).toUpperCase()}
|
||||
</div>
|
||||
<div className="identity-text">
|
||||
<strong>{user.name || "Account user"}</strong>
|
||||
<small>{user.email || "Signed in with ZITADEL"}</small>
|
||||
</div>
|
||||
</div>
|
||||
<form action={portalLogout}>
|
||||
<button type="submit" className="button button-subtle button-full">
|
||||
Sign out of portal
|
||||
</button>
|
||||
</form>
|
||||
</aside>
|
||||
<div className="main-column">
|
||||
<header className="topbar">
|
||||
<span className="topbar-label">Identity & security</span>
|
||||
<span className="status-dot"><span aria-hidden="true" /> Signed in</span>
|
||||
</header>
|
||||
<main id="main-content" className="main-content">
|
||||
{children}
|
||||
</main>
|
||||
<footer className="footer">
|
||||
ZitPlane Account Center · Authentication powered by ZITADEL
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user