fix login redirect
This commit is contained in:
parent
20b11886af
commit
bb3fb40995
3 changed files with 9 additions and 10 deletions
5
angular_app/js/app.js
vendored
5
angular_app/js/app.js
vendored
|
@ -33,6 +33,7 @@ var eventManApp = angular.module('eventManApp', [
|
|||
eventManApp.run(['$rootScope', '$state', '$stateParams', '$log', 'Info',
|
||||
function($rootScope, $state, $stateParams, $log, Info) {
|
||||
$rootScope.app_uuid = guid();
|
||||
$rootScope.info = {};
|
||||
$log.debug('App UUID: ' + $rootScope.app_uuid);
|
||||
$rootScope.$state = $state;
|
||||
$rootScope.$stateParams = $stateParams;
|
||||
|
@ -42,7 +43,9 @@ eventManApp.run(['$rootScope', '$state', '$stateParams', '$log', 'Info',
|
|||
$rootScope.readInfo = function(callback) {
|
||||
Info.get({}, function(data) {
|
||||
$rootScope.info = data || {};
|
||||
if (callback) {
|
||||
if (data.authentication_required && !(data.user && data.user._id)) {
|
||||
$state.go('login');
|
||||
} else if (callback) {
|
||||
callback(data);
|
||||
}
|
||||
});
|
||||
|
|
4
angular_app/js/controllers.js
vendored
4
angular_app/js/controllers.js
vendored
|
@ -7,8 +7,8 @@ var eventManControllers = angular.module('eventManControllers', []);
|
|||
|
||||
|
||||
/* A controller that can be used to navigate. */
|
||||
eventManControllers.controller('NavigationCtrl', ['$scope', '$rootScope', '$location', 'Setting', 'Info',
|
||||
function ($scope, $rootScope, $location, Setting, Info) {
|
||||
eventManControllers.controller('NavigationCtrl', ['$scope', '$rootScope', '$location', 'Setting', 'Info', '$state',
|
||||
function ($scope, $rootScope, $location, Setting, Info, $state) {
|
||||
$scope.logo = {};
|
||||
|
||||
$scope.getLocation = function() {
|
||||
|
|
|
@ -244,7 +244,6 @@ class RootHandler(BaseHandler):
|
|||
angular_app_path = os.path.join(os.path.dirname(__file__), "angular_app")
|
||||
|
||||
@gen.coroutine
|
||||
@authenticated
|
||||
def get(self, *args, **kwargs):
|
||||
# serve the ./angular_app/index.html file
|
||||
with open(self.angular_app_path + "/index.html", 'r') as fd:
|
||||
|
@ -866,12 +865,12 @@ class SettingsHandler(BaseHandler):
|
|||
class InfoHandler(BaseHandler):
|
||||
"""Handle requests for information about the logged in user."""
|
||||
@gen.coroutine
|
||||
@authenticated
|
||||
def get(self, **kwds):
|
||||
info = {}
|
||||
user_info = self.current_user_info
|
||||
if user_info:
|
||||
info['user'] = user_info
|
||||
info['authentication_required'] = self.authentication
|
||||
self.write({'info': info})
|
||||
|
||||
|
||||
|
@ -904,7 +903,7 @@ class WebSocketEventUpdatesHandler(tornado.websocket.WebSocketHandler):
|
|||
logging.warn('WebSocketEventUpdatesHandler.on_close error closing websocket: %s', str(e))
|
||||
|
||||
|
||||
class LoginHandler(BaseHandler):
|
||||
class LoginHandler(RootHandler):
|
||||
"""Handle user authentication requests."""
|
||||
|
||||
@gen.coroutine
|
||||
|
@ -914,9 +913,6 @@ class LoginHandler(BaseHandler):
|
|||
self.set_status(401)
|
||||
self.write({'error': True,
|
||||
'message': 'authentication required'})
|
||||
else:
|
||||
with open(self.angular_app_path + "/login.html", 'r') as fd:
|
||||
self.write(fd.read())
|
||||
|
||||
@gen.coroutine
|
||||
def post(self, *args, **kwargs):
|
||||
|
@ -1024,7 +1020,7 @@ def run():
|
|||
template_path=os.path.join(os.path.dirname(__file__), "templates"),
|
||||
static_path=os.path.join(os.path.dirname(__file__), "static"),
|
||||
cookie_secret='__COOKIE_SECRET__',
|
||||
login_url='/login',
|
||||
login_url='/#/login',
|
||||
debug=options.debug)
|
||||
ssl_options = {}
|
||||
if os.path.isfile(options.ssl_key) and os.path.isfile(options.ssl_cert):
|
||||
|
|
Loading…
Reference in a new issue