Commit 3030598a authored by Kostas Papadimitriou's avatar Kostas Papadimitriou Committed by Georgios D. Tsoukalas
Browse files

cyclades ui: Allow developers to disable logout redirects

using UI_AUTH_SKIP_REDIRECTS. Useful for developers coping with 401 cyclades
api responses.
parent da4ece94
......@@ -67,6 +67,8 @@
this.config = $.extend(this.default_config, config);
this.current_token = undefined;
this.current_username = undefined;
this.skip_redirects = config.skip_redirects === undefined ? false :
config.skip_redirects;
var self = this;
this.updater = window.setInterval(function(){
......@@ -85,15 +87,21 @@
}
snf.auth.AstakosClient.prototype.delete_cookie = function() {
if (!this.skip_redirects) {
$.cookie(this.config.cookie_name, null);
}
}
snf.auth.AstakosClient.prototype.redirect_to_logout = function() {
if (!this.skip_redirects) {
window.location = this.config.logout_url + "?next=";
}
}
snf.auth.AstakosClient.prototype.redirect_to_login = function() {
if (!this.skip_redirects) {
window.location = this.config.login_url + "?next=" + window.location.toString();
}
}
// delete cookie and redirect to logout
......
......@@ -658,6 +658,7 @@
login_url: synnefo.config.login_redirect,
logout_url: synnefo.config.logout_redirect,
cookie_name: synnefo.config.auth_cookie_name,
skip_redirects: {{ auth_skip_redirects|safe }},
logout_callback: function(client) {
Backbone.history.navigate(client.config.logout_url);
window.location = client.config.logout_url;
......
......@@ -89,6 +89,9 @@ UNKNOWN_OS = getattr(settings, "UI_UNKNOWN_OS", "unknown")
AUTH_COOKIE_NAME = getattr(settings, "UI_AUTH_COOKIE_NAME", 'synnefo_user')
# never change window location. Helpful in development environments
AUTH_SKIP_REDIRECTS = getattr(settings, "UI_AUTH_SKIP_REDIRECTS", False)
# UI behaviour settings
DELAY_ON_BLUR = getattr(settings, "UI_DELAY_ON_BLUR", True)
UPDATE_HIDDEN_VIEWS = getattr(settings, "UI_UPDATE_HIDDEN_VIEWS", False)
......@@ -204,6 +207,7 @@ def home(request):
'changes_since_alignment': CHANGES_SINCE_ALIGNMENT,
'image_icons': IMAGE_ICONS,
'auth_cookie_name': AUTH_COOKIE_NAME,
'auth_skip_redirects': json.dumps(AUTH_SKIP_REDIRECTS),
'suggested_flavors': json.dumps(SUGGESTED_FLAVORS),
'suggested_roles': json.dumps(SUGGESTED_ROLES),
'vm_image_common_metadata': json.dumps(VM_IMAGE_COMMON_METADATA),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment