parent
300e2d0b7d
commit
c8eca56690
@ -864,7 +864,7 @@ class Rolling(Command):
|
||||
|
||||
def main():
|
||||
manager.add_command("start", LemurServer())
|
||||
manager.add_command("runserver", Server(host='127.0.0.1'))
|
||||
manager.add_command("runserver", Server(host='127.0.0.1', threaded=True))
|
||||
manager.add_command("clean", Clean())
|
||||
manager.add_command("show_urls", ShowUrls())
|
||||
manager.add_command("db", MigrateCommand)
|
||||
|
12
lemur/static/app/angular/app.js
vendored
12
lemur/static/app/angular/app.js
vendored
@ -149,9 +149,17 @@
|
||||
});
|
||||
});
|
||||
|
||||
lemur.run(['$templateCache', function ($templateCache) {
|
||||
lemur.run(function ($templateCache, $location, $rootScope, $auth, $state) {
|
||||
$templateCache.put('ng-table/pager.html', '<div class="ng-cloak ng-table-pager"> <div ng-if="params.settings().counts.length" class="ng-table-counts btn-group pull-left"> <button ng-repeat="count in params.settings().counts" type="button" ng-class="{\'active\':params.count()==count}" ng-click="params.count(count)" class="btn btn-default"> <span ng-bind="count"></span> </button></div><div class="pull-right"><ul style="margin: 0; padding: 0;" class="pagination ng-table-pagination"> <li ng-class="{\'disabled\': !page.active}" ng-repeat="page in pages" ng-switch="page.type"> <a ng-switch-when="prev" ng-click="params.page(page.number)" href="">«</a> <a ng-switch-when="first" ng-click="params.page(page.number)" href=""><span ng-bind="page.number"></span></a> <a ng-switch-when="page" ng-click="params.page(page.number)" href=""><span ng-bind="page.number"></span></a> <a ng-switch-when="more" ng-click="params.page(page.number)" href="">…</a> <a ng-switch-when="last" ng-click="params.page(page.number)" href=""><span ng-bind="page.number"></span></a> <a ng-switch-when="next" ng-click="params.page(page.number)" href="">»</a> </li> </ul> </div></div>');
|
||||
}]);
|
||||
$rootScope.$on('$stateChangeStart', function(event, toState, toParams) {
|
||||
if (toState.name !== 'login') {
|
||||
if (!$auth.isAuthenticated()) {
|
||||
event.preventDefault();
|
||||
$state.go('login', {'toState': toState.name, 'toParams': toParams, notify: false});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
|
@ -5,12 +5,48 @@ angular.module('lemur')
|
||||
$stateProvider.state('login', {
|
||||
url: '/login',
|
||||
templateUrl: '/angular/authentication/login/login.tpl.html',
|
||||
controller: 'LoginController'
|
||||
controller: 'LoginController',
|
||||
params: {
|
||||
'toState': 'certificates',
|
||||
'toParams': {}
|
||||
}
|
||||
});
|
||||
})
|
||||
.controller('LoginController', function ($rootScope, $scope, AuthenticationService, UserService, providers) {
|
||||
$scope.login = AuthenticationService.login;
|
||||
$scope.authenticate = AuthenticationService.authenticate;
|
||||
.controller('LoginController', function ($rootScope, $scope, $state, $auth, AuthenticationService, UserService, providers, toaster) {
|
||||
$scope.login = function (username, password) {
|
||||
return AuthenticationService.login(username, password).then(
|
||||
function (user) {
|
||||
$auth.setToken(user.token, true);
|
||||
$rootScope.$emit('user:login');
|
||||
$state.go($state.params.toState, $state.params.toParams);
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: 'Whoa there',
|
||||
body: response.data.message,
|
||||
showCloseButton: true
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.authenticate = function (provider) {
|
||||
return AuthenticationService.authenticate(provider).then(
|
||||
function (user) {
|
||||
$auth.setToken(user.token, true);
|
||||
$rootScope.$emit('user:login');
|
||||
$state.go($state.params.toState, $state.params.toParams);
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: 'Whoa there',
|
||||
body: response.data.message,
|
||||
showCloseButton: true
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.logout = AuthenticationService.logout;
|
||||
|
||||
$scope.providers = providers;
|
||||
@ -28,4 +64,4 @@ angular.module('lemur')
|
||||
$rootScope.$on('user:logout', function () {
|
||||
$scope.currentUser = null;
|
||||
});
|
||||
});
|
||||
});
|
@ -7,40 +7,11 @@ angular.module('lemur')
|
||||
var AuthenticationService = this;
|
||||
|
||||
AuthenticationService.login = function (username, password) {
|
||||
AuthenticationApi.customPOST({'username': username, 'password': password}, 'login')
|
||||
.then(
|
||||
function (user) {
|
||||
$auth.setToken(user.token, true);
|
||||
$rootScope.$emit('user:login');
|
||||
$location.url('/certificates');
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: 'Whoa there',
|
||||
body: response.data.message,
|
||||
showCloseButton: true
|
||||
});
|
||||
}
|
||||
);
|
||||
return AuthenticationApi.customPOST({'username': username, 'password': password}, 'login');
|
||||
};
|
||||
|
||||
AuthenticationService.authenticate = function (provider) {
|
||||
$auth.authenticate(provider)
|
||||
.then(
|
||||
function () {
|
||||
UserService.getCurrentUser();
|
||||
$rootScope.$emit('user:login');
|
||||
$location.url('/certificates');
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: 'Something went wrong',
|
||||
body: response.data.message
|
||||
});
|
||||
}
|
||||
);
|
||||
return $auth.authenticate(provider);
|
||||
};
|
||||
|
||||
AuthenticationService.logout = function () {
|
||||
@ -55,8 +26,7 @@ angular.module('lemur')
|
||||
title: 'Good job!',
|
||||
body: 'You have been successfully logged out.'
|
||||
});
|
||||
$location.path('/');
|
||||
$location.path('/login');
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user