Show bootstrap alert after login.
This commit is contained in:
parent
e0b9e4e719
commit
b835956ea9
2 changed files with 14 additions and 0 deletions
|
|
@ -16,6 +16,18 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{% block nav %}{{ navbar() }}{% endblock %}
|
{% block nav %}{{ navbar() }}{% endblock %}
|
||||||
|
{% with messages = get_flashed_messages() %}
|
||||||
|
{% if messages %}
|
||||||
|
<div class="container-fluid mt-2">
|
||||||
|
{% for message in messages %}
|
||||||
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||||
|
{{ message }}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
<script src="{{ url_for("static", filename="bootstrap5/js/bootstrap.bundle.min.js") }}"></script>
|
<script src="{{ url_for("static", filename="bootstrap5/js/bootstrap.bundle.min.js") }}"></script>
|
||||||
|
|
|
||||||
|
|
@ -868,11 +868,13 @@ def auth_callback() -> werkzeug.Response:
|
||||||
except Exception:
|
except Exception:
|
||||||
return flask.redirect(flask.url_for("login"))
|
return flask.redirect(flask.url_for("login"))
|
||||||
userinfo = token.get("userinfo") or oauth.authentik.userinfo()
|
userinfo = token.get("userinfo") or oauth.authentik.userinfo()
|
||||||
|
username = userinfo.get("preferred_username") or userinfo.get("email")
|
||||||
flask.session["user"] = {
|
flask.session["user"] = {
|
||||||
"sub": userinfo["sub"],
|
"sub": userinfo["sub"],
|
||||||
"username": userinfo.get("preferred_username"),
|
"username": userinfo.get("preferred_username"),
|
||||||
"email": userinfo.get("email"),
|
"email": userinfo.get("email"),
|
||||||
}
|
}
|
||||||
|
flask.flash(f"Logged in as {username}")
|
||||||
next_url = flask.session.pop("login_next", flask.url_for("index"))
|
next_url = flask.session.pop("login_next", flask.url_for("index"))
|
||||||
return flask.redirect(next_url)
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue