Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

feat: enhance auth check logic to handle password hash absence

t8y2684877f56332
diff --git a/src-web/src/auth.rs b/src-web/src/auth.rs
index c8c3ae97cd..5205591108 100644
--- a/src-web/src/auth.rs
+++ b/src-web/src/auth.rs
@@ -56,11 +56,15 @@ pub async fn login(
.into_response())
}
-pub async fn check(State(state): State<Arc<WebState>>) -> Json<AuthCheckResponse> {
- Json(AuthCheckResponse {
- authenticated: state.password_hash.is_none(),
- required: state.password_hash.is_some(),
- })
+pub async fn check(State(state): State<Arc<WebState>>, req: Request<axum::body::Body>) -> Json<AuthCheckResponse> {
+ if state.password_hash.is_none() {
+ return Json(AuthCheckResponse { authenticated: true, required: false });
+ }
+ let authenticated = match extract_session_token(&req) {
+ Some(token) => state.sessions.read().await.contains(&token),
+ None => false,
+ };
+ Json(AuthCheckResponse { authenticated, required: true })
}
pub async fn logout(State(state): State<Arc<WebState>>, req: Request<axum::body::Body>) -> Response {