add: user account switcher
This commit is contained in:
parent
48e0b02198
commit
20aae5570b
13 changed files with 172 additions and 34 deletions
|
@ -48,6 +48,12 @@
|
|||
]);
|
||||
|
||||
if (res.ok) {
|
||||
// update tokens
|
||||
const new_tokens = ns("me").LOGIN_ACCOUNT_TOKENS;
|
||||
new_tokens[e.target.username.value] = res.message;
|
||||
trigger("me::set_login_account_tokens", [new_tokens]);
|
||||
|
||||
// redirect
|
||||
setTimeout(() => {
|
||||
window.location.href = "/";
|
||||
}, 150);
|
||||
|
|
|
@ -100,6 +100,12 @@
|
|||
]);
|
||||
|
||||
if (res.ok) {
|
||||
// update tokens
|
||||
const new_tokens = ns("me").LOGIN_ACCOUNT_TOKENS;
|
||||
new_tokens[e.target.username.value] = res.message;
|
||||
trigger("me::set_login_account_tokens", [new_tokens]);
|
||||
|
||||
// redirect
|
||||
setTimeout(() => {
|
||||
window.location.href = "/";
|
||||
}, 150);
|
||||
|
|
|
@ -107,6 +107,11 @@ show_lhs=true) -%}
|
|||
</a>
|
||||
|
||||
<div class="title"></div>
|
||||
<button onclick="trigger('me::switch_account')">
|
||||
{{ icon "ellipsis" }}
|
||||
<span>{{ text "general:action.switch_account" }}</span>
|
||||
</button>
|
||||
|
||||
<button class="red" onclick="trigger('me::logout')">
|
||||
{{ icon "log-out" }}
|
||||
<span>{{ text "auth:action.logout" }}</span>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% import "macros.html" as macros %} {% extends "profile/base.html" %} {% block
|
||||
content %} {% if config.town_square %}
|
||||
content %} {% if config.town_square and is_self %}
|
||||
<div class="card-nest">
|
||||
<div class="card small flex flex-col">
|
||||
<div class="flex items-center gap-2">
|
||||
|
|
|
@ -109,6 +109,12 @@
|
|||
atto["hooks::check_reactions"]();
|
||||
atto["hooks::tabs"]();
|
||||
atto["hooks::partial_embeds"]();
|
||||
|
||||
if (document.getElementById("tokens")) {
|
||||
trigger("me::render_token_picker", [
|
||||
document.getElementById("tokens"),
|
||||
]);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -257,5 +263,38 @@
|
|||
</form>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
{% if user %}
|
||||
<dialog id="tokens_dialog">
|
||||
<div class="inner flex flex-col gap-2">
|
||||
<form
|
||||
class="flex gap-2 flex-col"
|
||||
onsubmit="event.preventDefault()"
|
||||
>
|
||||
<div id="tokens" style="display: contents"></div>
|
||||
|
||||
<a href="/auth/login" class="button" data-turbo="false">
|
||||
{{ icon "plus" }}
|
||||
<span>{{ text "general:action.add_account" }}</span>
|
||||
</a>
|
||||
|
||||
<div class="flex justify-between">
|
||||
<div></div>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<button
|
||||
class="quaternary"
|
||||
onclick="document.getElementById('tokens_dialog').close()"
|
||||
type="button"
|
||||
>
|
||||
{{ icon "check" }}
|
||||
<span>{{ text "dialog:action.okay" }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</dialog>
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue