+14
-4
src/main.py
+14
-4
src/main.py
···
116
116
@app.route("/auth/logout")
117
117
def auth_logout():
118
118
session.clear()
119
-
return redirect("/", 303)
119
+
return redirect(url_for("page_login"), 303)
120
120
121
121
122
122
@app.get("/editor")
123
123
async def page_editor():
124
124
user = get_user()
125
125
if user is None:
126
-
return redirect("/login")
126
+
return redirect("/login", 302)
127
127
128
128
did: str = user.did
129
129
pds: str = user.pds_url
···
152
152
async def post_editor_profile():
153
153
user = get_user()
154
154
if user is None:
155
-
return redirect("/login", 303)
155
+
url = url_for("auth_logout")
156
+
return htmx_response(redirect=url) if htmx else redirect(url, 303)
156
157
157
158
display_name = request.form.get("displayName")
158
159
description = request.form.get("description", "")
···
177
178
if success:
178
179
kv = KV(app, app.logger, "profile_from_did")
179
180
kv.set(user.did, json.dumps(record))
181
+
else:
182
+
app.logger.warning("log out user for now")
183
+
url = url_for("auth_logout")
184
+
return htmx_response(redirect=url) if htmx else redirect(url, 303)
180
185
181
186
if htmx:
182
187
return htmx_response(
···
191
196
async def post_editor_links():
192
197
user = get_user()
193
198
if user is None:
194
-
return redirect("/login", 303)
199
+
url = url_for("auth_logout")
200
+
return htmx_response(redirect=url) if htmx else redirect(url, 303)
195
201
196
202
links: list[dict[str, str]] = []
197
203
hrefs = request.form.getlist("link-href")
···
232
238
if success:
233
239
kv = KV(app, app.logger, "links_from_did")
234
240
kv.set(user.did, json.dumps(record))
241
+
else:
242
+
app.logger.warning("log out user for now")
243
+
url = url_for("auth_logout")
244
+
return htmx_response(redirect=url) if htmx else redirect(url, 303)
235
245
236
246
if htmx:
237
247
return htmx_response(
+5
-1
src/templates/_editor_links.html
+5
-1
src/templates/_editor_links.html
···
6
6
</template>
7
7
</div>
8
8
9
+
<noscript>
10
+
JavaScript is needed for a better experience configuring the links.
11
+
</noscript>
12
+
9
13
<form
10
14
method="post"
11
15
action="/editor/links"
···
29
33
<div x-show="!editing">
30
34
<link-editor-buttons>
31
35
<button type="button" @click="editing = true">edit</button>
32
-
<button type="button" @click="if (confirm('delete ' + link.title + '?')) links.splice(index, 1)">delete</button>
36
+
<button type="button" @click="if (confirm('delete ' + link.title + '?')) { linksChanged = true; links.splice(index, 1); }">delete</button>
33
37
</link-editor-buttons>
34
38
</div>
35
39
<div x-show="editing">