mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-20 13:54:36 +01:00
Add login page docs hint (#20619)
* add config field * add endpoint * set config var when onboarding * add no auth exception to nginx config * form changes and i18n * clean up
This commit is contained in:
@@ -35,6 +35,23 @@ logger = logging.getLogger(__name__)
|
||||
router = APIRouter(tags=[Tags.auth])
|
||||
|
||||
|
||||
@router.get("/auth/first_time_login")
|
||||
def first_time_login(request: Request):
|
||||
"""Return whether the admin first-time login help flag is set in config.
|
||||
|
||||
This endpoint is intentionally unauthenticated so the login page can
|
||||
query it before a user is authenticated.
|
||||
"""
|
||||
auth_config = request.app.frigate_config.auth
|
||||
|
||||
return JSONResponse(
|
||||
content={
|
||||
"admin_first_time_login": auth_config.admin_first_time_login
|
||||
or auth_config.reset_admin_password
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class RateLimiter:
|
||||
_limit = ""
|
||||
|
||||
@@ -515,6 +532,11 @@ def login(request: Request, body: AppPostLoginBody):
|
||||
set_jwt_cookie(
|
||||
response, JWT_COOKIE_NAME, encoded_jwt, expiration, JWT_COOKIE_SECURE
|
||||
)
|
||||
# Clear admin_first_time_login flag after successful admin login so the
|
||||
# UI stops showing the first-time login documentation link.
|
||||
if role == "admin":
|
||||
request.app.frigate_config.auth.admin_first_time_login = False
|
||||
|
||||
return response
|
||||
return JSONResponse(content={"message": "Login failed"}, status_code=401)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user