fix password auto-fill
All checks were successful
Build and Deploy Website / build (push) Successful in 2m27s
All checks were successful
Build and Deploy Website / build (push) Successful in 2m27s
This commit is contained in:
@@ -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");
|
||||||
|
|||||||
Reference in New Issue
Block a user