diff --git a/src/server/fastapi_app.py b/src/server/fastapi_app.py index e33ce66..b1e7b29 100644 --- a/src/server/fastapi_app.py +++ b/src/server/fastapi_app.py @@ -343,6 +343,31 @@ async def logout(current_user: Dict = Depends(get_current_user)) -> Dict[str, An "message": "Logged out successfully. Please remove the token from client storage." } +@app.get("/api/auth/status", response_model=Dict[str, Any], tags=["Authentication"]) +async def auth_status(request: Request) -> Dict[str, Any]: + """ + Check authentication status and configuration. + + This endpoint checks if master password is configured and if user is authenticated. + """ + has_master_password = bool(settings.master_password_hash or settings.master_password) + + # Check if user has valid token + authenticated = False + try: + auth_header = request.headers.get("authorization") + if auth_header and auth_header.startswith("Bearer "): + token = auth_header.split(" ")[1] + payload = verify_jwt_token(token) + authenticated = payload is not None + except Exception: + authenticated = False + + return { + "has_master_password": has_master_password, + "authenticated": authenticated + } + # Health check endpoint @app.get("/health", response_model=HealthResponse, tags=["System"]) async def health_check() -> HealthResponse: diff --git a/src/server/web/templates/base/setup.html b/src/server/web/templates/base/setup.html index 0d91784..b4e1a95 100644 --- a/src/server/web/templates/base/setup.html +++ b/src/server/web/templates/base/setup.html @@ -1,5 +1,6 @@ +
@@ -15,7 +16,7 @@ background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary) 100%); padding: 1rem; } - + .setup-card { background: var(--color-surface); border-radius: 16px; @@ -25,50 +26,50 @@ max-width: 500px; border: 1px solid var(--color-border); } - + .setup-header { text-align: center; margin-bottom: 2rem; } - + .setup-header .logo { font-size: 3rem; color: var(--color-primary); margin-bottom: 0.5rem; } - + .setup-header h1 { margin: 0; color: var(--color-text); font-size: 1.8rem; font-weight: 600; } - + .setup-header p { margin: 1rem 0 0 0; color: var(--color-text-secondary); font-size: 1rem; line-height: 1.5; } - + .setup-form { display: flex; flex-direction: column; gap: 1.5rem; } - + .form-group { display: flex; flex-direction: column; gap: 0.5rem; } - + .form-label { font-weight: 500; color: var(--color-text); font-size: 0.9rem; } - + .form-input { width: 100%; padding: 0.75rem 1rem; @@ -80,21 +81,21 @@ transition: all 0.2s ease; box-sizing: border-box; } - + .form-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1); } - + .password-input-group { position: relative; } - + .password-input { padding-right: 3rem; } - + .password-toggle { position: absolute; right: 0.75rem; @@ -108,17 +109,17 @@ border-radius: 4px; transition: color 0.2s ease; } - + .password-toggle:hover { color: var(--color-primary); } - + .password-strength { display: flex; gap: 0.25rem; margin-top: 0.5rem; } - + .strength-bar { flex: 1; height: 4px; @@ -126,24 +127,35 @@ border-radius: 2px; transition: background-color 0.2s ease; } - - .strength-bar.active.weak { background: var(--color-error); } - .strength-bar.active.fair { background: var(--color-warning); } - .strength-bar.active.good { background: var(--color-info); } - .strength-bar.active.strong { background: var(--color-success); } - + + .strength-bar.active.weak { + background: var(--color-error); + } + + .strength-bar.active.fair { + background: var(--color-warning); + } + + .strength-bar.active.good { + background: var(--color-info); + } + + .strength-bar.active.strong { + background: var(--color-success); + } + .strength-text { font-size: 0.8rem; color: var(--color-text-secondary); margin-top: 0.25rem; } - + .form-help { font-size: 0.8rem; color: var(--color-text-secondary); line-height: 1.4; } - + .setup-button { width: 100%; padding: 0.75rem; @@ -160,20 +172,20 @@ justify-content: center; gap: 0.5rem; } - + .setup-button:hover:not(:disabled) { background: var(--color-primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.3); } - + .setup-button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; } - + .error-message { background: var(--color-error-light); color: var(--color-error); @@ -182,7 +194,7 @@ border: 1px solid var(--color-error); font-size: 0.9rem; } - + .success-message { background: var(--color-success-light); color: var(--color-success); @@ -191,7 +203,7 @@ border: 1px solid var(--color-success); font-size: 0.9rem; } - + .security-tips { margin-top: 1.5rem; padding: 1rem; @@ -201,19 +213,19 @@ font-size: 0.85rem; color: var(--color-text-secondary); } - + .security-tips h4 { margin: 0 0 0.5rem 0; color: var(--color-info); font-size: 0.9rem; } - + .security-tips ul { margin: 0; padding-left: 1.2rem; line-height: 1.4; } - + .theme-toggle { position: absolute; top: 1rem; @@ -231,12 +243,12 @@ align-items: center; justify-content: center; } - + .theme-toggle:hover { background: rgba(255, 255, 255, 0.2); transform: scale(1.1); } - + .loading-spinner { width: 1rem; height: 1rem; @@ -245,7 +257,7 @@ border-radius: 50%; animation: spin 1s linear infinite; } - + @keyframes spin { to { transform: rotate(360deg); @@ -253,12 +265,13 @@ } +Let's set up your master password to secure your anime collection.