parent
f3f9ee5bf9
commit
8f749c8e35
4 changed files with 43 additions and 9 deletions
21
web_view.py
21
web_view.py
|
|
@ -28,11 +28,15 @@ app = flask.Flask(__name__)
|
|||
app.debug = False
|
||||
app.config.from_object("config.default")
|
||||
|
||||
app.before_request(UniAuth.auth.require_authentication)
|
||||
|
||||
agenda.error_mail.setup_error_mail(app)
|
||||
|
||||
|
||||
@app.before_request
|
||||
def handle_auth() -> None:
|
||||
"""Handle autentication and set global user."""
|
||||
flask.g.user = UniAuth.auth.get_current_user()
|
||||
|
||||
|
||||
@app.errorhandler(werkzeug.exceptions.InternalServerError)
|
||||
def exception_handler(e: werkzeug.exceptions.InternalServerError) -> tuple[str, int]:
|
||||
"""Handle exception."""
|
||||
|
|
@ -369,5 +373,18 @@ def auth_callback() -> tuple[str, int] | werkzeug.Response:
|
|||
return UniAuth.auth.auth_callback()
|
||||
|
||||
|
||||
@app.route("/login")
|
||||
def login() -> werkzeug.Response:
|
||||
"""Login."""
|
||||
next_url = flask.request.args["next"]
|
||||
return UniAuth.auth.redirect_to_login(next_url)
|
||||
|
||||
|
||||
@app.route("/logout")
|
||||
def logout() -> werkzeug.Response:
|
||||
"""Logout."""
|
||||
return UniAuth.auth.redirect_to_logout(flask.request.args["next"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue