Add /api/auth/status endpoint for JavaScript compatibility
This commit is contained in:
parent
2c8c9a788c
commit
e3b752a2a7
@ -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."
|
"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
|
# Health check endpoint
|
||||||
@app.get("/health", response_model=HealthResponse, tags=["System"])
|
@app.get("/health", response_model=HealthResponse, tags=["System"])
|
||||||
async def health_check() -> HealthResponse:
|
async def health_check() -> HealthResponse:
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" data-theme="light">
|
<html lang="en" data-theme="light">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
@ -127,10 +128,21 @@
|
|||||||
transition: background-color 0.2s ease;
|
transition: background-color 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.strength-bar.active.weak { background: var(--color-error); }
|
.strength-bar.active.weak {
|
||||||
.strength-bar.active.fair { background: var(--color-warning); }
|
background: var(--color-error);
|
||||||
.strength-bar.active.good { background: var(--color-info); }
|
}
|
||||||
.strength-bar.active.strong { background: var(--color-success); }
|
|
||||||
|
.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 {
|
.strength-text {
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
@ -253,6 +265,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="setup-container">
|
<div class="setup-container">
|
||||||
<button class="theme-toggle" id="theme-toggle" title="Toggle theme">
|
<button class="theme-toggle" id="theme-toggle" title="Toggle theme">
|
||||||
@ -271,14 +284,8 @@
|
|||||||
<form class="setup-form" id="setup-form">
|
<form class="setup-form" id="setup-form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="directory" class="form-label">Anime Directory</label>
|
<label for="directory" class="form-label">Anime Directory</label>
|
||||||
<input
|
<input type="text" id="directory" name="directory" class="form-input" placeholder="C:\Anime"
|
||||||
type="text"
|
value="{{ current_directory }}" required>
|
||||||
id="directory"
|
|
||||||
name="directory"
|
|
||||||
class="form-input"
|
|
||||||
placeholder="C:\Anime"
|
|
||||||
value="{{ current_directory }}"
|
|
||||||
required>
|
|
||||||
<div class="form-help">
|
<div class="form-help">
|
||||||
The directory where your anime series are stored. This can be changed later in settings.
|
The directory where your anime series are stored. This can be changed later in settings.
|
||||||
</div>
|
</div>
|
||||||
@ -287,14 +294,8 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password" class="form-label">Master Password</label>
|
<label for="password" class="form-label">Master Password</label>
|
||||||
<div class="password-input-group">
|
<div class="password-input-group">
|
||||||
<input
|
<input type="password" id="password" name="password" class="form-input password-input"
|
||||||
type="password"
|
placeholder="Create a strong password" required minlength="8">
|
||||||
id="password"
|
|
||||||
name="password"
|
|
||||||
class="form-input password-input"
|
|
||||||
placeholder="Create a strong password"
|
|
||||||
required
|
|
||||||
minlength="8">
|
|
||||||
<button type="button" class="password-toggle" id="password-toggle" tabindex="-1">
|
<button type="button" class="password-toggle" id="password-toggle" tabindex="-1">
|
||||||
<i class="fas fa-eye"></i>
|
<i class="fas fa-eye"></i>
|
||||||
</button>
|
</button>
|
||||||
@ -311,13 +312,8 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="confirm-password" class="form-label">Confirm Password</label>
|
<label for="confirm-password" class="form-label">Confirm Password</label>
|
||||||
<div class="password-input-group">
|
<div class="password-input-group">
|
||||||
<input
|
<input type="password" id="confirm-password" name="confirm-password"
|
||||||
type="password"
|
class="form-input password-input" placeholder="Confirm your password" required
|
||||||
id="confirm-password"
|
|
||||||
name="confirm-password"
|
|
||||||
class="form-input password-input"
|
|
||||||
placeholder="Confirm your password"
|
|
||||||
required
|
|
||||||
minlength="8">
|
minlength="8">
|
||||||
<button type="button" class="password-toggle" id="confirm-password-toggle" tabindex="-1">
|
<button type="button" class="password-toggle" id="confirm-password-toggle" tabindex="-1">
|
||||||
<i class="fas fa-eye"></i>
|
<i class="fas fa-eye"></i>
|
||||||
@ -560,4 +556,5 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user