Skip to content
Snippets Groups Projects
Commit 7902c7fc authored by Arie Peterson's avatar Arie Peterson
Browse files

Merge branch '125-improve-signup-ux' into 'main'

Redirect to dashboard if not redirect login is set, on succesful login

See merge request !99
parents 62e5bafe da62615a
No related branches found
No related tags found
1 merge request!99Redirect to dashboard if not redirect login is set, on succesful login
Pipeline #38912 passed with stages
in 2 minutes and 55 seconds
...@@ -146,7 +146,10 @@ def login(): ...@@ -146,7 +146,10 @@ def login():
name = " " + identity['traits']['name'] name = " " + identity['traits']['name']
else: else:
name = "" name = ""
return render_template("loggedin.html", api_url=KRATOS_PUBLIC_URL, dashboard_url=DASHBOARD_URL, name=name) return render_template("loggedin.html",
api_url=KRATOS_PUBLIC_URL,
dashboard_url=DASHBOARD_URL,
name=name)
# If we do not have a flow, get one. # If we do not have a flow, get one.
if not flow: if not flow:
......
...@@ -16,16 +16,32 @@ ...@@ -16,16 +16,32 @@
*/ */
// In default configuration the dashboed is on '/'. This can be overwritten
// before calling the scripts (and configured by the flask app
var dashboard_url = '';
// Check if an auth flow is configured and redirect to auth page in that // Check if an auth flow is configured and redirect to auth page in that
// case. // case.
function check_flow_auth() { function check_flow_auth() {
var state = Cookies.get('flow_state'); var state = Cookies.get('flow_state');
var url = Cookies.get('auth_url'); var url = Cookies.get('auth_url');
// Redirect to the specified URL
if (state == 'auth') { if (state == 'auth') {
Cookies.set('flow_state', ''); Cookies.set('flow_state', '');
window.location.href = url; window.location.href = url;
return;
}
// Some older stackspin releases, do not provide the dashboard_url,
// flask writes 'None' as string in that case, we want to cover those
// cases and revert to the default
if (dashboard_url == 'None'|| dashboard_url == '') {
dashboard_url = window.location.protocol + "//" + window.location.host;
} }
// If no redirect is set, redirect to dashboard
window.location.href = dashboard_url + '/login';
} }
// Check if there if the flow is expired, if so, reset the cookie // Check if there if the flow is expired, if so, reset the cookie
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<script> <script>
var api_url = '{{ api_url }}'; var api_url = '{{ api_url }}';
var dashboard_url = '{{ dashboard_url }}';
// Actions // Actions
$(document).ready(function() { $(document).ready(function() {
...@@ -17,8 +18,7 @@ ...@@ -17,8 +18,7 @@
<div id="contentMessages"></div> <div id="contentMessages"></div>
<div id="contentWelcome"> <div id="contentWelcome">
Welcome{{ name }}, you are logged in. Welcome{{ name }}, you are logged in. We are redirecting you....
</div> </div>
{% endblock %} {% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment