fix: more login/session issues addressed

This commit is contained in:
Andy Burke 2025-07-04 15:16:51 -07:00
parent cf46450f5f
commit ee152a514c
8 changed files with 85 additions and 51 deletions

View file

@ -28,6 +28,12 @@
attributeFilter: ["data-user"],
});
</script>
<style>
.profile-container {
margin: 1rem auto;
max-width: 1024px;
}
</style>
<div id="user" class="tab">
<input
type="radio"
@ -41,36 +47,38 @@
<div class="label">Profile</div></label
>
<div class="tab-content">
<div class="avatar-container">
<img
id="user-avatar"
src="/images/default_avatar.gif"
alt="User Avatar"
data-bind-user_meta_avatar="src"
/>
<div class="profile-container">
<div class="avatar-container">
<img
id="user-avatar"
src="/images/default_avatar.gif"
alt="User Avatar"
data-bind-user_meta_avatar="src"
/>
</div>
<div class="username-container">
<span class="username" data-bind-user_username></span>
</div>
<form data-smart="true" data-method="DELETE" action="/api/auth">
<script>
{
const form = document.currentScript.closest("form");
form.on_response = (response) => {
if (!response.deleted) {
alert("error logging out? please reload.");
return;
}
delete document.body.dataset.user;
delete document.body.dataset.perms;
window.location = "/";
};
}
</script>
<button class="primary">Log Out</button>
</form>
</div>
<div class="username-container">
<span class="username" data-bind-user_username></span>
</div>
<form data-smart="true" action="/api/auth" method="DELETE">
<script>
{
const form = document.currentScript.closest("form");
form.on_response = (response) => {
if (!response.ok) {
alert("error logging out!");
return;
}
delete document.body.dataset.user;
delete document.body.dataset.perms;
window.location = "/";
};
}
</script>
<button class="primary">Log Out</button>
</form>
</div>
</div>

View file

@ -133,5 +133,5 @@
<!-- #include file="./work.html" -->
<!-- #include file="./resources.html" -->
<!-- #include file="./calendar.html" -->
<!-- #include file="./user.html" -->
<!-- #include file="./profile.html" -->
</div>

View file

@ -211,7 +211,7 @@
users[event.creator_id] =
users[event.creator_id] ??
(await api.fetch(`/users/${event.creator_id}`));
(await api.fetch(`/api/users/${event.creator_id}`));
room_chat_content.insertAdjacentHTML(
"beforeend",
@ -233,7 +233,7 @@
return;
}
const message_polling_url = `/rooms/${room_id}/events?type=chat&limit=100&sort=newest&wait=true${last_message_id ? `&after_id=${last_message_id}` : ""}`;
const message_polling_url = `/api/rooms/${room_id}/events?type=chat&limit=100&sort=newest&wait=true${last_message_id ? `&after_id=${last_message_id}` : ""}`;
room_polling_request_abort_controller =
room_polling_request_abort_controller || new AbortController();
@ -264,7 +264,7 @@
delete room_chat_content.dataset.last_message_id;
}
const room_response = await api.fetch(`/rooms/${room_id}`);
const room_response = await api.fetch(`/api/rooms/${room_id}`);
if (!room_response.ok) {
const error = await room_response.json();
alert(error.message ?? JSON.stringify(error));
@ -285,7 +285,7 @@
}
const events_response = await api.fetch(
`/rooms/${room_id}/events?type=chat&limit=100&sort=newest`,
`/api/rooms/${room_id}/events?type=chat&limit=100&sort=newest`,
);
if (!events_response.ok) {
const error = await events_response.json();
@ -309,7 +309,7 @@
return;
}
const rooms_response = await api.fetch("/rooms");
const rooms_response = await api.fetch("/api/rooms");
if (rooms_response.ok) {
const room_list = document.getElementById("room-list");
room_list.innerHTML = "";
@ -411,7 +411,7 @@
render_text_event(message_event, user),
);
const event_response = await api.fetch(`/rooms/${room_id}/events`, {
const event_response = await api.fetch(`/api/rooms/${room_id}/events`, {
method: "POST",
json: message_event,
});
@ -484,7 +484,7 @@
editable.addEventListener("focusout", async () => {
const name = editable.textContent ?? editable.innerText;
const new_room_response = await api.fetch("/rooms", {
const new_room_response = await api.fetch("/api/rooms", {
method: "POST",
json: {
name,