Add unauthorized_handler to UI

This commit is contained in:
Théophile Diot 2023-02-15 15:18:57 +01:00
parent 5ac64758e3
commit c671ccf7a2
No known key found for this signature in database
GPG key ID: E752C80DB72BB014

View file

@ -253,6 +253,13 @@ def load_user(user_id):
return User(user_id, vars["ADMIN_PASSWORD"]) return User(user_id, vars["ADMIN_PASSWORD"])
@login_manager.unauthorized_handler
def unauthorized_callback():
if request.path == "/":
return redirect(url_for("login"))
return "Unauthorized", 401
# CSRF protection # CSRF protection
csrf = CSRFProtect() csrf = CSRFProtect()
csrf.init_app(app) csrf.init_app(app)