Merge pull request #4000 from dannon/error_message_for_login_required

Displaying a message instead of just redirecting
This commit is contained in:
Aysam Guerler
2017-05-01 15:20:43 -04:00
committed by GitHub
5 changed files with 47 additions and 30 deletions
+18 -2
View File
@@ -69,6 +69,18 @@ window.app = function app( options, bootstrapped ){
Galaxy.currHistoryPanel = historyPanel.historyView;
Galaxy.currHistoryPanel.listenToGalaxy( Galaxy );
var routingMessage = Backbone.View.extend({
initialize: function(options) {
this.message = options.message || "Undefined Message";
this.msg_status = options.type || 'info';
this.render();
},
render: function(){
this.$el.html(_.escape(this.message)).addClass(this.msg_status + "message");
}
});
// .................................................... routes
/** */
Galaxy.router = new ( Backbone.Router.extend({
@@ -98,7 +110,7 @@ window.app = function app( options, bootstrapped ){
if ( this.authenticate( args, name ) ) {
callback.apply( this, args );
} else {
this.push( Galaxy.root );
this.loginRequired();
}
}
},
@@ -117,6 +129,10 @@ window.app = function app( options, bootstrapped ){
'show_user_form'
],
loginRequired: function() {
centerPanel.display( new routingMessage({type: 'error', message: "You must be logged in to make this request."}) );
},
authenticate: function( args, name ) {
return ( Galaxy.user && Galaxy.user.id ) || this.require_login.indexOf( name ) == -1;
},
@@ -209,4 +225,4 @@ window.app = function app( options, bootstrapped ){
pushState : true,
});
});
};
};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long