feat: add privacy retention controls

This commit is contained in:
2026-07-19 05:52:48 +08:00
parent c6079bbb47
commit 2af99a4b43
6 changed files with 30 additions and 2 deletions
+3 -1
View File
@@ -1,7 +1,9 @@
import { redirect } from "next/navigation";
import { getSession } from "@/lib/auth";
import { db } from "@/lib/db";
export default async function Account({ searchParams }: { searchParams: Promise<{ error?: string; updated?: string }> }) {
const user = await getSession(); if (!user) redirect("/login"); const query = await searchParams;
return <><h1></h1>{query.error && <p className="error">{query.error}</p>}{query.updated && <p></p>}<section className="card"><p className="meta">{user.username}</p><h2></h2><form action="/api/auth/password" method="post"><label><input name="currentPassword" type="password" autoComplete="current-password" required /></label><label><input name="newPassword" type="password" autoComplete="new-password" minLength={10} required /></label><label><input name="confirmPassword" type="password" autoComplete="new-password" minLength={10} required /></label><button></button></form></section></>;
const ownedSources = db.prepare("SELECT count(*) AS count FROM sources WHERE user_id=?").get(user.id) as { count: number };
return <><h1></h1>{query.error && <p className="error">{query.error}</p>}{query.updated && <p></p>}<section className="card"><p className="meta">{user.username}</p><h2></h2><form action="/api/auth/password" method="post"><label><input name="currentPassword" type="password" autoComplete="current-password" required /></label><label><input name="newPassword" type="password" autoComplete="new-password" minLength={10} required /></label><label><input name="confirmPassword" type="password" autoComplete="new-password" minLength={10} required /></label><button></button></form></section><section className="card"><h2></h2>{ownedSources.count ? <p className="error"> {ownedSources.count} </p> : <form action="/api/auth/delete" method="post"><p className="meta"> Hub </p><label><input name="currentPassword" type="password" autoComplete="current-password" required /></label><label> DELETE <input name="confirmation" required /></label><button className="danger"></button></form>}</section></>;
}