✨ (user): Respeta las preferencias por usuario
This commit is contained in:
parent
0472e698ae
commit
a29f0f2b75
24 changed files with 239 additions and 201 deletions
|
|
@ -3,7 +3,7 @@
|
|||
use pagetop::prelude::*;
|
||||
use pagetop_htmx::prelude::*;
|
||||
|
||||
use crate::config::SETTINGS;
|
||||
use crate::config;
|
||||
use crate::{LOCALES_USER, LOGIN_PATH, LOGOUT_PATH, PROFILE_PATH, REGISTER_PATH};
|
||||
|
||||
/// Construye el menú de cuenta como un [`Nav`] justificado al final de su contenedor.
|
||||
|
|
@ -59,7 +59,7 @@ pub fn account_menu(cx: &Context) -> Nav {
|
|||
Lc::t("menu-login", &LOCALES_USER),
|
||||
cx.route(LOGIN_PATH),
|
||||
));
|
||||
if SETTINGS.allow_registration {
|
||||
if config::SETTINGS.allow_registration {
|
||||
nav.with_item(nav::Item::link(
|
||||
Lc::t("link-register", &LOCALES_USER),
|
||||
cx.route(REGISTER_PATH),
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
use crate::LOCALES_USER;
|
||||
use crate::config::{SETTINGS, user_language_applies, user_timezone_applies};
|
||||
use crate::config;
|
||||
use crate::user_path;
|
||||
use crate::{ADMIN_USERS_PATH, PROFILE_EDIT_PATH};
|
||||
|
||||
|
|
@ -102,12 +102,12 @@ impl Component for UserForm {
|
|||
} else if username_readonly {
|
||||
Lc::none()
|
||||
} else {
|
||||
username_help(SETTINGS.identity_policy)
|
||||
username_help(config::SETTINGS.identity_policy)
|
||||
})
|
||||
.with_required(true)
|
||||
.with_readonly(username_readonly)
|
||||
.with_minlength(USERNAME_MIN_CHARS)
|
||||
.with_maxlength(username_max_chars(SETTINGS.identity_policy)),
|
||||
.with_maxlength(username_max_chars(config::SETTINGS.identity_policy)),
|
||||
)
|
||||
.with_child(
|
||||
form::input::Field::email()
|
||||
|
|
@ -135,9 +135,9 @@ impl Component for UserForm {
|
|||
.with_maxlength(DISPLAY_NAME_MAX_CHARS),
|
||||
);
|
||||
|
||||
// Sólo se ofrecen si se aplican (ver `config::user_language_applies()` y
|
||||
// `config::user_timezone_applies()`).
|
||||
if user_language_applies() {
|
||||
// Sólo se ofrecen si se aplican (ver `config::user_language_applies()`,
|
||||
// `config::user_timezone_applies()` y `config::user_theme_applies()`).
|
||||
if config::user_language_applies() {
|
||||
form = form.with_child(
|
||||
form::SelectLanguage::new()
|
||||
.with_name("language")
|
||||
|
|
@ -146,7 +146,7 @@ impl Component for UserForm {
|
|||
.with_selected(self.language()),
|
||||
);
|
||||
}
|
||||
if user_timezone_applies() {
|
||||
if config::user_timezone_applies() {
|
||||
form = form.with_child(
|
||||
form::SelectTimezone::new()
|
||||
.with_name("timezone")
|
||||
|
|
@ -156,13 +156,15 @@ impl Component for UserForm {
|
|||
.with_selected(self.timezone()),
|
||||
);
|
||||
}
|
||||
form = form.with_child(
|
||||
form::SelectTheme::new()
|
||||
.with_name("theme")
|
||||
.with_label(Lc::t("field-theme", &LOCALES_USER))
|
||||
.with_disabled(managed(UserField::Theme))
|
||||
.with_selected(self.theme()),
|
||||
);
|
||||
if config::user_theme_applies() {
|
||||
form = form.with_child(
|
||||
form::SelectTheme::new()
|
||||
.with_name("theme")
|
||||
.with_label(Lc::t("field-theme", &LOCALES_USER))
|
||||
.with_disabled(managed(UserField::Theme))
|
||||
.with_selected(self.theme()),
|
||||
);
|
||||
}
|
||||
|
||||
match (self.mode(), self.provider()) {
|
||||
// Una cuenta que entrará con un proveedor no tiene contraseña local.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
use crate::component::error_banner;
|
||||
use crate::config::SETTINGS;
|
||||
use crate::config;
|
||||
use crate::provider::{self, HelpLink, ResetLink};
|
||||
use crate::{LOCALES_USER, LOGIN_PATH, PASSWORD_RESET_PATH, REGISTER_PATH};
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ impl Component for LoginForm {
|
|||
|
||||
async fn prepare(&self, cx: &mut Context) -> Result<Markup, ComponentError> {
|
||||
let action = self.waypoint().append_to(cx.route(LOGIN_PATH));
|
||||
let strict = SETTINGS.login.strict;
|
||||
let strict = config::SETTINGS.login.strict;
|
||||
let (notes, reset) = provider::login_hints();
|
||||
|
||||
// En modo estricto se dificulta que el navegador recuerde o autorrellene las
|
||||
|
|
@ -83,7 +83,7 @@ impl Component for LoginForm {
|
|||
Button::submit(Lc::t("btn-login", &LOCALES_USER))
|
||||
.with_style(button::Style::Solid(Intent::Primary)),
|
||||
)
|
||||
.with_child(links(SETTINGS.allow_registration, notes, reset));
|
||||
.with_child(links(config::SETTINGS.allow_registration, notes, reset));
|
||||
|
||||
if strict {
|
||||
form = form
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
use crate::LOCALES_USER;
|
||||
use crate::config::SETTINGS;
|
||||
use crate::config;
|
||||
|
||||
/// Campos de contraseña y confirmación, compuestos a partir de
|
||||
/// [`form::input::Field::password()`] del core. No valida en ningún momento que ambos valores
|
||||
|
|
@ -35,7 +35,7 @@ impl Component for PasswordConfirm {
|
|||
// `minlength` cuenta unidades UTF-16 y el servidor caracteres: con caracteres fuera del
|
||||
// plano básico (emojis) el navegador puede aceptar una contraseña que el servidor rechaza,
|
||||
// pero nunca al revés.
|
||||
let min_length = SETTINGS.password.min_length;
|
||||
let min_length = config::SETTINGS.password.min_length;
|
||||
let mut password = form::input::Field::password()
|
||||
.with_name("password")
|
||||
.with_label(self.password_label().clone())
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use pagetop::prelude::*;
|
|||
use crate::LOCALES_USER;
|
||||
use crate::REGISTER_PATH;
|
||||
use crate::component::{PasswordConfirm, error_banner};
|
||||
use crate::config::SETTINGS;
|
||||
use crate::config;
|
||||
use crate::identity::{EMAIL_MAX_CHARS, USERNAME_MIN_CHARS, username_help, username_max_chars};
|
||||
|
||||
/// Formulario de registro de una cuenta nueva.
|
||||
|
|
@ -37,9 +37,9 @@ impl Component for RegisterForm {
|
|||
.with_name("username")
|
||||
.with_value(&self.username)
|
||||
.with_label(Lc::t("field-username-admin", &LOCALES_USER))
|
||||
.with_help_text(username_help(SETTINGS.identity_policy))
|
||||
.with_help_text(username_help(config::SETTINGS.identity_policy))
|
||||
.with_minlength(USERNAME_MIN_CHARS)
|
||||
.with_maxlength(username_max_chars(SETTINGS.identity_policy))
|
||||
.with_maxlength(username_max_chars(config::SETTINGS.identity_policy))
|
||||
.with_autocomplete(Some(form::Autocomplete::username()))
|
||||
.with_autofocus(true)
|
||||
.with_required(true),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue