feat: add anonymous checkbox to redact author on guestbook
All checks were successful
create archive with lfs / tag (push) Successful in 10s
All checks were successful
create archive with lfs / tag (push) Successful in 10s
This commit is contained in:
parent
a73fe75141
commit
a2e6eb2af4
@ -21,12 +21,13 @@ const postAction = (client: any, scopes: string[]) => {
|
||||
scopedCookies.set("postAuth", client.name)
|
||||
const form = await request.formData()
|
||||
const content = form.get("content")?.toString().substring(0, 512)
|
||||
const anon = !(form.get("anon") === null)
|
||||
if (content === undefined) {
|
||||
scopedCookies.set("sendError", "content field is missing")
|
||||
redirect(303, auth.callbackUrl)
|
||||
}
|
||||
// save form content in a cookie
|
||||
const params = new URLSearchParams({ content })
|
||||
const params = new URLSearchParams({ content, anon: anon ? "1" : "" })
|
||||
scopedCookies.set("postData", params.toString())
|
||||
// get auth url to redirect user to
|
||||
const authUrl = auth.createAuthUrl((state) => client.getAuthUrl(state, scopes), cookies)
|
||||
@ -80,8 +81,9 @@ export async function load({ url, fetch, cookies }) {
|
||||
let respRaw: Response
|
||||
try {
|
||||
const postData = new URLSearchParams(rawPostData)
|
||||
// set author to the identified value we got
|
||||
postData.set('author', author)
|
||||
const anon = (postData.get('anon') ?? "1").length > 0
|
||||
// set author to the identified value we got if not anonymous
|
||||
postData.set('author', anon ? "[REDACTED]" : author)
|
||||
// return error if content was not set or if empty
|
||||
const content = postData.get('content')
|
||||
if (content === null || content.trim().length === 0) {
|
||||
|
@ -36,7 +36,11 @@
|
||||
maxlength="512"
|
||||
required
|
||||
/>
|
||||
<p class="place-self-end text-sm font-monospace">--- posted by ...</p>
|
||||
<div class="flex flex-row gap-2 items-center justify-center">
|
||||
<input type="checkbox" id="anon" name="anon" checked/>
|
||||
<label for="anon" class="text-sm font-monospace grow text-shadow-white">post anonymously</label>
|
||||
<p class="text-sm font-monospace">--- posted by ...</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="entry flex flex-wrap gap-1.5 p-1">
|
||||
<p class="text-xl ms-2">auth via:</p>
|
||||
|
Loading…
Reference in New Issue
Block a user