add: better profile settings mobile ui
add: allow Atto-Grant cookie to act auth token for oauth grants
This commit is contained in:
parent
5844d23399
commit
ca8f510a3a
4 changed files with 90 additions and 38 deletions
|
@ -77,7 +77,26 @@ macro_rules! create_dir_if_not_exists {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! get_user_from_token {
|
macro_rules! get_user_from_token {
|
||||||
($jar:ident, $db:expr) => {{
|
($jar:ident, $db:expr) => {{
|
||||||
if let Some(token) = $jar.get("__Secure-atto-token") {
|
if let Some(token) = $jar.get("Atto-Grant") {
|
||||||
|
// this allows us to ALSO authenticate with a grant token...
|
||||||
|
// TODO: require macro to pass a required AppScope to check permission
|
||||||
|
// TODO: check token verifier
|
||||||
|
match $db
|
||||||
|
.get_user_by_grant_token(&tetratto_shared::hash::hash(
|
||||||
|
token.to_string().replace("Atto-Grant=", ""),
|
||||||
|
))
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok((_, ua)) => {
|
||||||
|
if ua.permissions.check_banned() {
|
||||||
|
Some(tetratto_core::model::auth::User::banned())
|
||||||
|
} else {
|
||||||
|
Some(ua)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(_) => None,
|
||||||
|
}
|
||||||
|
} else if let Some(token) = $jar.get("__Secure-atto-token") {
|
||||||
match $db
|
match $db
|
||||||
.get_user_by_token(&tetratto_shared::hash::hash(
|
.get_user_by_token(&tetratto_shared::hash::hash(
|
||||||
token.to_string().replace("__Secure-atto-token=", ""),
|
token.to_string().replace("__Secure-atto-token=", ""),
|
||||||
|
|
|
@ -268,3 +268,37 @@
|
||||||
(icon (text "circle-dot"))
|
(icon (text "circle-dot"))
|
||||||
(str (text "forge:tab.tickets"))))
|
(str (text "forge:tab.tickets"))))
|
||||||
(text "{%- endmacro %}")
|
(text "{%- endmacro %}")
|
||||||
|
|
||||||
|
(text "{% macro profile_settings_nav_options() -%}")
|
||||||
|
(a
|
||||||
|
("data-tab-button" "account")
|
||||||
|
("class" "active")
|
||||||
|
("href" "#/account")
|
||||||
|
(text "{{ icon \"smile\" }}")
|
||||||
|
(span
|
||||||
|
(text "{{ text \"settings:tab.account\" }}")))
|
||||||
|
(a
|
||||||
|
("data-tab-button" "profile")
|
||||||
|
("href" "#/profile")
|
||||||
|
(text "{{ icon \"user-round\" }}")
|
||||||
|
(span
|
||||||
|
(text "{{ text \"settings:tab.profile\" }}")))
|
||||||
|
(a
|
||||||
|
("data-tab-button" "theme")
|
||||||
|
("href" "#/theme")
|
||||||
|
(text "{{ icon \"paint-bucket\" }}")
|
||||||
|
(span
|
||||||
|
(text "{{ text \"settings:tab.theme\" }}")))
|
||||||
|
(a
|
||||||
|
("data-tab-button" "sessions")
|
||||||
|
("href" "#/sessions")
|
||||||
|
(text "{{ icon \"cookie\" }}")
|
||||||
|
(span
|
||||||
|
(text "{{ text \"settings:tab.sessions\" }}")))
|
||||||
|
(a
|
||||||
|
("data-tab-button" "connections")
|
||||||
|
("href" "#/connections")
|
||||||
|
(text "{{ icon \"cable\" }}")
|
||||||
|
(span
|
||||||
|
(text "{{ text \"settings:tab.connections\" }}")))
|
||||||
|
(text "{%- endmacro %}")
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(text "{% extends \"root.html\" %} {% block head %}")
|
(text "{% extends \"root.html\" %} {% block head %}")
|
||||||
(title
|
(title
|
||||||
(text "Settings - {{ config.name }}"))
|
(text "Settings - {{ config.name }}"))
|
||||||
|
|
||||||
(text "{% endblock %} {% block body %} {{ macros::nav() }}")
|
(text "{% endblock %} {% block body %} {{ macros::nav() }}")
|
||||||
(main
|
(main
|
||||||
("class" "flex flex-col gap-2")
|
("class" "flex flex-col gap-2")
|
||||||
|
@ -12,39 +11,30 @@
|
||||||
(b
|
(b
|
||||||
(text "Editing other user's settings! Please be careful.")))
|
(text "Editing other user's settings! Please be careful.")))
|
||||||
(text "{%- endif %}")
|
(text "{%- endif %}")
|
||||||
|
|
||||||
|
; nav
|
||||||
(div
|
(div
|
||||||
("class" "pillmenu")
|
("class" "mobile_nav mobile")
|
||||||
(a
|
; primary nav
|
||||||
("data-tab-button" "account")
|
(div
|
||||||
("class" "active")
|
("class" "dropdown")
|
||||||
("href" "#/account")
|
("style" "width: max-content")
|
||||||
(text "{{ icon \"smile\" }}")
|
(button
|
||||||
(span
|
("class" "camo raised small")
|
||||||
(text "{{ text \"settings:tab.account\" }}")))
|
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||||
(a
|
("exclude" "dropdown")
|
||||||
("data-tab-button" "profile")
|
(icon (text "sliders-horizontal"))
|
||||||
("href" "#/profile")
|
(span ("class" "current_tab_text") (text "account")))
|
||||||
(text "{{ icon \"user-round\" }}")
|
(div
|
||||||
(span
|
("class" "inner left")
|
||||||
(text "{{ text \"settings:tab.profile\" }}")))
|
(text "{{ macros::profile_settings_nav_options() }}"))))
|
||||||
(a
|
|
||||||
("data-tab-button" "theme")
|
; nav desktop
|
||||||
("href" "#/theme")
|
(div
|
||||||
(text "{{ icon \"paint-bucket\" }}")
|
("class" "desktop pillmenu")
|
||||||
(span
|
(text "{{ macros::profile_settings_nav_options() }}"))
|
||||||
(text "{{ text \"settings:tab.theme\" }}")))
|
|
||||||
(a
|
; ...
|
||||||
("data-tab-button" "sessions")
|
|
||||||
("href" "#/sessions")
|
|
||||||
(text "{{ icon \"cookie\" }}")
|
|
||||||
(span
|
|
||||||
(text "{{ text \"settings:tab.sessions\" }}")))
|
|
||||||
(a
|
|
||||||
("data-tab-button" "connections")
|
|
||||||
("href" "#/connections")
|
|
||||||
(text "{{ icon \"cable\" }}")
|
|
||||||
(span
|
|
||||||
(text "{{ text \"settings:tab.connections\" }}"))))
|
|
||||||
(div
|
(div
|
||||||
("class" "w-full flex flex-col gap-2")
|
("class" "w-full flex flex-col gap-2")
|
||||||
("data-tab" "account")
|
("data-tab" "account")
|
||||||
|
|
|
@ -704,12 +704,21 @@ media_theme_pref();
|
||||||
for (const element of Array.from(
|
for (const element of Array.from(
|
||||||
document.querySelectorAll("[data-tab-button]"),
|
document.querySelectorAll("[data-tab-button]"),
|
||||||
)) {
|
)) {
|
||||||
element.classList.remove("active");
|
if (element.getAttribute("data-tab-button") !== tab) {
|
||||||
|
element.classList.remove("active");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document
|
for (const element of document.querySelectorAll(
|
||||||
.querySelector(`[data-tab-button="${tab}"]`)
|
`[data-tab-button="${tab}"]`,
|
||||||
.classList.add("active");
|
)) {
|
||||||
|
element.classList.add("active");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update text elements
|
||||||
|
for (const element of document.querySelectorAll(".current_tab_text")) {
|
||||||
|
element.innerText = tab;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue