Skip to content

Commit

Permalink
feat: allow update passwd
Browse files Browse the repository at this point in the history
  • Loading branch information
SharzyL committed Apr 11, 2024
1 parent 68d107c commit f6de922
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async function handlePostOrPut(request, env, ctx, isPut) {
const filename = form.get("c") && getDispFilename(form.get("c").fields)
const name = form.get("n") && decode(form.get("n").content)
const isPrivate = form.get("p") !== undefined
const passwd = form.get("s") && decode(form.get("s").content)
const newPasswd = form.get("s") && decode(form.get("s").content)
const expire =
form.has("e") && form.get("e").content.byteLength > 0
? decode(form.get("e").content)
Expand Down Expand Up @@ -140,7 +140,7 @@ async function handlePostOrPut(request, env, ctx, isPut) {
throw new WorkerError(403, `incorrect password for paste '${short}`)
} else {
return makeResponse(
await createPaste(env, content, isPrivate, expirationSeconds, short, date, passwd, filename),
await createPaste(env, content, isPrivate, expirationSeconds, short, date, newPasswd || passwd, filename),
)
}
}
Expand All @@ -152,7 +152,7 @@ async function handlePostOrPut(request, env, ctx, isPut) {
throw new WorkerError(409, `name '${name}' is already used`)
}
return makeResponse(await createPaste(
env, content, isPrivate, expirationSeconds, short, undefined, passwd, filename
env, content, isPrivate, expirationSeconds, short, undefined, newPasswd, filename,
))
}
}
Expand Down

0 comments on commit f6de922

Please sign in to comment.