fix password auto-fill
All checks were successful
Build and Deploy Website / build (push) Successful in 2m27s

This commit is contained in:
2026-02-28 23:14:54 -08:00
parent 500c080d02
commit 35289a04f2

View File

@@ -36,15 +36,17 @@ export default function PasteView() {
>("loading"); >("loading");
const [copied, setCopied] = useState(false); const [copied, setCopied] = useState(false);
const [linkCopied, setLinkCopied] = useState(false); const [linkCopied, setLinkCopied] = useState(false);
const [passwordInput, setPasswordInput] = useState( const [passwordInput, setPasswordInput] = useState("");
(location.state as { password?: string })?.password ?? "",
);
const [passwordError, setPasswordError] = useState<string | null>(null); const [passwordError, setPasswordError] = useState<string | null>(null);
const [unlocking, setUnlocking] = useState(false); const [unlocking, setUnlocking] = useState(false);
const initialPassword = (location.state as { password?: string })?.password;
useEffect(() => { useEffect(() => {
if (!id) return; if (!id) return;
fetch(`/api/paste/${id}`) const headers: HeadersInit = {};
if (initialPassword) headers["X-Paste-Password"] = initialPassword;
fetch(`/api/paste/${id}`, { headers })
.then((res) => { .then((res) => {
if (res.status === 404) { if (res.status === 404) {
setStatus("notfound"); setStatus("notfound");