add: user associations

This commit is contained in:
trisua 2025-06-05 20:56:56 -04:00
parent 50319f9124
commit 675b3e4ee6
11 changed files with 131 additions and 9 deletions

View file

@ -188,6 +188,20 @@
);
}, 100);
}, 150);"))))
(div
("class" "card-nest w-full")
(div
("class" "card small flex items-center justify-between gap-2")
(div
("class" "flex items-center gap-2")
(text "{{ icon \"users-round\" }}")
(span
(text "{{ text \"mod_panel:label.associations\" }}"))))
(div
("class" "card tertiary flex flex-wrap gap-2")
(text "{% for user in associations -%}")
(text "{{ components::user_plate(user=user, show_menu=false) }}")
(text "{%- endfor %}")))
(div
("class" "card-nest w-full")
(div

View file

@ -74,6 +74,7 @@
(text "{% if user and user.id == post.owner -%}")
(a
("href" "/post/{{ post.id }}#/edit")
("data-tab-button" "edit")
(text "{{ icon \"pen\" }}")
(span
(text "{{ text \"communities:label.edit_content\" }}")))

View file

@ -455,6 +455,26 @@
});
// token switcher
self.define("append_associations", (_, tokens) => {
fetch("/api/v1/auth/user/me/append_associations", {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
tokens,
}),
})
.then((res) => res.json())
.then((res) => {
if (res.ok) {
console.log("associations sent");
} else {
console.warn(res.message);
}
});
});
self.define(
"set_login_account_tokens",
({ $ }, value) => {
@ -474,7 +494,10 @@
return;
}
window.location.href = `/api/v1/auth/token?token=${token}`;
self.append_associations([token]);
setTimeout(() => {
window.location.href = `/api/v1/auth/token?token=${token}`;
}, 150);
});
self.define("remove_token", async (_, username) => {