fix(web client): sidebar shows login link for anonymous with a nickname

This commit is contained in:
Henri Bourcereau 2026-05-24 16:22:50 +02:00
parent 2f40a0a507
commit 91981e6872
6 changed files with 32 additions and 126 deletions

View file

@ -2,6 +2,7 @@ use leptos::prelude::*;
use leptos_router::hooks::use_navigate;
use crate::api;
use crate::app::AuthEmailVerified;
use crate::i18n::*;
#[component]
@ -9,8 +10,8 @@ pub fn AccountPage() -> impl IntoView {
let i18n = use_i18n();
let auth_username =
use_context::<RwSignal<Option<String>>>().expect("auth_username context not found");
let auth_email_verified =
use_context::<RwSignal<bool>>().expect("auth_email_verified context not found");
let auth_email_verified = use_context::<AuthEmailVerified>()
.expect("auth_email_verified context not found").0;
let navigate = use_navigate();
// Only redirect to profile when the email is actually verified.
@ -107,8 +108,8 @@ fn LoginForm() -> impl IntoView {
let i18n = use_i18n();
let auth_username =
use_context::<RwSignal<Option<String>>>().expect("auth_username context not found");
let auth_email_verified =
use_context::<RwSignal<bool>>().expect("auth_email_verified context not found");
let auth_email_verified = use_context::<AuthEmailVerified>()
.expect("auth_email_verified context not found").0;
let navigate = use_navigate();
let login = RwSignal::new(String::new());
@ -177,8 +178,8 @@ fn RegisterForm() -> impl IntoView {
let i18n = use_i18n();
let auth_username =
use_context::<RwSignal<Option<String>>>().expect("auth_username context not found");
let auth_email_verified =
use_context::<RwSignal<bool>>().expect("auth_email_verified context not found");
let auth_email_verified = use_context::<AuthEmailVerified>()
.expect("auth_email_verified context not found").0;
let username = RwSignal::new(String::new());
let email = RwSignal::new(String::new());

View file

@ -3,7 +3,7 @@ use leptos::prelude::*;
use leptos_router::components::A;
use leptos_router::hooks::use_query_map;
use crate::app::{NetCommand, Screen};
use crate::app::{AnonNickname, NetCommand, Screen};
use crate::i18n::*;
// ── Room/nickname generation ──────────────────────────────────────────────────
@ -103,7 +103,7 @@ pub fn LobbyPage() -> impl IntoView {
let cmd_tx = use_context::<UnboundedSender<NetCommand>>().expect("NetCommand sender");
let auth_username = use_context::<RwSignal<Option<String>>>().expect("auth_username context");
let auth_loaded = use_context::<RwSignal<bool>>().expect("auth_loaded context");
let anon_nickname = use_context::<RwSignal<Option<String>>>().expect("anon_nickname context");
let anon_nickname = use_context::<AnonNickname>().expect("anon_nickname context").0;
let query = use_query_map();
let view_state: RwSignal<LobbyView> = RwSignal::new(LobbyView::Idle);

View file

@ -2,6 +2,7 @@ use leptos::prelude::*;
use leptos_router::hooks::use_query_map;
use crate::api;
use crate::app::AuthEmailVerified;
use crate::i18n::*;
#[derive(Clone, PartialEq)]
@ -16,8 +17,8 @@ pub fn VerifyEmailPage() -> impl IntoView {
let i18n = use_i18n();
let auth_username =
use_context::<RwSignal<Option<String>>>().expect("auth_username context not found");
let auth_email_verified =
use_context::<RwSignal<bool>>().expect("auth_email_verified context not found");
let auth_email_verified = use_context::<AuthEmailVerified>()
.expect("auth_email_verified context not found").0;
let query = use_query_map();
let token = query.with(|m| m.get("token").map(|s| s.to_string()).unwrap_or_default());