Quick fix for displaying a message instead of just redirecting on clientside routes when login is required. TODO: refactor both message display and the decoration of routes.

This commit is contained in:
Dannon Baker
2017-05-01 14:58:59 -04:00
parent 4c1f9c8f0d
commit d638e37705
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