From b2d30f67da8b00569c52eebe8e56e4a3371138aa Mon Sep 17 00:00:00 2001 From: ping Date: Fri, 21 Aug 2026 10:48:48 +0000 Subject: [PATCH] fix(auth): preserve local identity mode --- crates/aionui-auth/src/routes.rs | 6 +----- crates/aionui-auth/tests/route_tests.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/crates/aionui-auth/src/routes.rs b/crates/aionui-auth/src/routes.rs index 72e162a2b..1a3a4d412 100644 --- a/crates/aionui-auth/src/routes.rs +++ b/crates/aionui-auth/src/routes.rs @@ -249,11 +249,7 @@ pub fn auth_routes(state: AuthRouterState) -> Router { let auth_state = AuthState { jwt_service: state.jwt_service.clone(), user_repo: state.user_repo.clone(), - identity_mode: if state.aionpro_mode { - AuthIdentityMode::AionPro - } else { - AuthIdentityMode::UserSession - }, + identity_mode: state.identity_mode, // Auth endpoints manage sessions themselves; the helper CLI never // calls them, so the runtime-token channel stays disabled here. runtime_token_verifier: None, diff --git a/crates/aionui-auth/tests/route_tests.rs b/crates/aionui-auth/tests/route_tests.rs index 5dee18f14..9ee910a86 100644 --- a/crates/aionui-auth/tests/route_tests.rs +++ b/crates/aionui-auth/tests/route_tests.rs @@ -498,6 +498,20 @@ async fn t7_3_get_user_no_token() { assert_eq!(json["code"], "UNAUTHORIZED"); } +#[tokio::test] +async fn t7_4_get_user_local_mode_without_token() { + let (app, _ctx) = test_app_with_local(true).await; + + let req = get_anonymous("/api/auth/user"); + let resp = app.oneshot(req).await.unwrap(); + + assert_eq!(resp.status(), StatusCode::OK); + let json = body_json(resp).await; + assert_eq!(json["success"], true); + assert_eq!(json["user"]["id"], "system_default_user"); + assert_eq!(json["user"]["username"], "system_default_user"); +} + // =========================================================================== // T8. Change Password (POST /api/auth/change-password) // ===========================================================================