1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Redirect to license page if no license

This was broken due to the upgrade to UI-Router v.1.0.0-beta.3.
I also tracked down the $stateChangeStart function in app.js that when missing
some time in 3.1 development
This commit is contained in:
jaredevantabor 2016-12-05 19:46:36 -08:00
parent 95f54b59cf
commit fe29f5e0c9
2 changed files with 53 additions and 5 deletions

View File

@ -385,6 +385,11 @@ var tower = angular.module('Tower', [
};
$rootScope.$stateParams = $stateParams;
$state.defaultErrorHandler(function() {
// Do not log transitionTo errors
// $log.debug("transitionTo error: " + error );
});
I18NInit();
$stateExtender.addState({
name: 'dashboard',
@ -681,9 +686,52 @@ var tower = angular.module('Tower', [
$rootScope.crumbCache = [];
// $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState) {
// SocketService.subscribe(toState, toParams);
// });
$rootScope.$on("$stateChangeStart", function (event, next) {
// Remove any lingering intervals
// except on jobDetails.* states
var jobDetailStates = [
'jobDetail',
'jobDetail.host-summary',
'jobDetail.host-event.details',
'jobDetail.host-event.json',
'jobDetail.host-events',
'jobDetail.host-event.stdout'
];
if ($rootScope.jobDetailInterval && !_.includes(jobDetailStates, next.name) ) {
window.clearInterval($rootScope.jobDetailInterval);
}
if ($rootScope.jobStdOutInterval && !_.includes(jobDetailStates, next.name) ) {
window.clearInterval($rootScope.jobStdOutInterval);
}
// On each navigation request, check that the user is logged in
if (!/^\/(login|logout)/.test($location.path())) {
// capture most recent URL, excluding login/logout
$rootScope.lastPath = $location.path();
$rootScope.enteredPath = $location.path();
$cookieStore.put('lastPath', $location.path());
}
if (Authorization.isUserLoggedIn() === false) {
if (next.name !== "signIn") {
$state.go('signIn');
}
} else if ($rootScope && $rootScope.sessionTimer && $rootScope.sessionTimer.isExpired()) {
// gets here on timeout
if (next.name !== "signIn") {
$state.go('signIn');
}
} else {
if ($rootScope.current_user === undefined || $rootScope.current_user === null) {
Authorization.restoreUserInfo(); //user must have hit browser refresh
}
if (next && (next.name !== "signIn" && next.name !== "signOut" && next.name !== "license")) {
// if not headed to /login or /logout, then check the license
CheckLicense.test(event);
}
}
activateTab();
});
$rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState) {

View File

@ -42,10 +42,10 @@ export default
if(license === null || !$rootScope.license_tested){
if(this.valid(license) === false) {
$rootScope.licenseMissing = true;
$state.go('license');
if(event){
event.preventDefault();
}
$state.go('license');
}
else {
$rootScope.licenseMissing = false;
@ -53,7 +53,7 @@ export default
}
else if(this.valid(license) === false) {
$rootScope.licenseMissing = true;
$state.transitionTo('license');
$state.go('license');
if(event){
event.preventDefault();
}