mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-08 06:01:22 +00:00
GUAC-1126: Re-route user within route config.
This commit is contained in:
@@ -32,7 +32,6 @@ angular.module('home').controller('homeController', ['$scope', '$injector',
|
|||||||
// Get required services
|
// Get required services
|
||||||
var authenticationService = $injector.get("authenticationService");
|
var authenticationService = $injector.get("authenticationService");
|
||||||
var connectionGroupService = $injector.get("connectionGroupService");
|
var connectionGroupService = $injector.get("connectionGroupService");
|
||||||
var userPageService = $injector.get("userPageService");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The root connection group, or null if the connection group hierarchy has
|
* The root connection group, or null if the connection group hierarchy has
|
||||||
@@ -61,10 +60,4 @@ angular.module('home').controller('homeController', ['$scope', '$injector',
|
|||||||
$scope.rootConnectionGroup = rootConnectionGroup;
|
$scope.rootConnectionGroup = rootConnectionGroup;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Navigate to home page, if not already there
|
|
||||||
userPageService.getHomePage()
|
|
||||||
.then(function homePageRetrieved(homePage) {
|
|
||||||
$location.url(homePage.url);
|
|
||||||
});
|
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
@@ -62,6 +62,57 @@ angular.module('index').config(['$routeProvider', '$locationProvider',
|
|||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirects the user to their home page. This necessarily requires
|
||||||
|
* attempting to re-authenticate with the Guacamole server, as the user's
|
||||||
|
* credentials may have changed, and thus their most-appropriate home page
|
||||||
|
* may have changed as well.
|
||||||
|
*
|
||||||
|
* @param {Service} $injector
|
||||||
|
* The Angular $injector service.
|
||||||
|
*
|
||||||
|
* @returns {Promise}
|
||||||
|
* A promise which resolves successfully only after an attempt to
|
||||||
|
* re-authenticate and determine the user's proper home page has been
|
||||||
|
* made.
|
||||||
|
*/
|
||||||
|
var routeToUserHomePage = ['$injector', function routeToUserHomePage($injector) {
|
||||||
|
|
||||||
|
// Required services
|
||||||
|
var $location = $injector.get('$location');
|
||||||
|
var $q = $injector.get('$q');
|
||||||
|
var userPageService = $injector.get('userPageService');
|
||||||
|
|
||||||
|
// Promise for redirection attempt
|
||||||
|
var redirect = $q.defer();
|
||||||
|
|
||||||
|
// Re-authenticate including any parameters in URL
|
||||||
|
$injector.invoke(updateCurrentToken)
|
||||||
|
.then(function tokenUpdateComplete() {
|
||||||
|
|
||||||
|
// Redirect to home page
|
||||||
|
userPageService.getHomePage()
|
||||||
|
.then(function homePageRetrieved(homePage) {
|
||||||
|
$location.url(homePage.url);
|
||||||
|
})
|
||||||
|
|
||||||
|
// If retrieval of home page fails, assume '/'
|
||||||
|
['catch'](function homePageFailed() {
|
||||||
|
$location.url('/');
|
||||||
|
})
|
||||||
|
|
||||||
|
// Resolve promise in either case
|
||||||
|
['finally'](function retrievalAttemptComplete() {
|
||||||
|
redirect.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// Return promise that will resolve regardless of success/failure
|
||||||
|
return redirect.promise;
|
||||||
|
|
||||||
|
}];
|
||||||
|
|
||||||
// Configure each possible route
|
// Configure each possible route
|
||||||
$routeProvider
|
$routeProvider
|
||||||
|
|
||||||
@@ -71,7 +122,7 @@ angular.module('index').config(['$routeProvider', '$locationProvider',
|
|||||||
bodyClassName : 'home',
|
bodyClassName : 'home',
|
||||||
templateUrl : 'app/home/templates/home.html',
|
templateUrl : 'app/home/templates/home.html',
|
||||||
controller : 'homeController',
|
controller : 'homeController',
|
||||||
resolve : { updateCurrentToken: updateCurrentToken }
|
resolve : { routeToUserHomePage: routeToUserHomePage }
|
||||||
})
|
})
|
||||||
|
|
||||||
// Connection management screen
|
// Connection management screen
|
||||||
@@ -147,9 +198,7 @@ angular.module('index').config(['$routeProvider', '$locationProvider',
|
|||||||
|
|
||||||
// Redirect to home screen if page not found
|
// Redirect to home screen if page not found
|
||||||
.otherwise({
|
.otherwise({
|
||||||
redirectTo : '/'
|
resolve : { routeToUserHomePage: routeToUserHomePage }
|
||||||
});
|
});
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -29,6 +29,7 @@ angular.module('index', [
|
|||||||
'home',
|
'home',
|
||||||
'login',
|
'login',
|
||||||
'manage',
|
'manage',
|
||||||
|
'navigation',
|
||||||
'ngRoute',
|
'ngRoute',
|
||||||
'ngTouch',
|
'ngTouch',
|
||||||
'notification',
|
'notification',
|
||||||
|
Reference in New Issue
Block a user