Defer bootstrapping angular until authenticated
This commit is contained in:
parent
46f7e1f7fc
commit
6cd10dc6b0
3 changed files with 18 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
|||
<!doctype html>
|
||||
<html lang="en" data-ng-app="keycloak">
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
|
|
@ -4,6 +4,23 @@ var module = angular.module('keycloak', [ 'keycloak.services', 'keycloak.loaders
|
|||
var resourceRequests = 0;
|
||||
var loadingTimer = -1;
|
||||
|
||||
angular.element(document).ready(function ($http) {
|
||||
$http.get('/auth-server/rest/saas/whoami').success(function(data) {
|
||||
var auth = {};
|
||||
auth.user = data;
|
||||
auth.loggedIn = true;
|
||||
|
||||
module.factory('Auth', function() {
|
||||
return auth;
|
||||
});
|
||||
angular.bootstrap(document, ["keycloak"]);
|
||||
}).error(function() {
|
||||
var path = window.location.hash && window.location.hash.substring(1) || '/';
|
||||
window.location = '/auth-server/rest/saas/login?path=' + path;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module.config([ '$routeProvider', function($routeProvider) {
|
||||
|
||||
$routeProvider
|
||||
|
|
|
@ -2,17 +2,6 @@
|
|||
|
||||
var module = angular.module('keycloak.services', [ 'ngResource' ]);
|
||||
|
||||
module.service('Auth', function() {
|
||||
var auth = {
|
||||
loggedIn : false
|
||||
};
|
||||
auth.user = {
|
||||
userId : null,
|
||||
displayName : null
|
||||
};
|
||||
return auth;
|
||||
});
|
||||
|
||||
module.service('Dialog', function($dialog) {
|
||||
var dialog = {};
|
||||
|
||||
|
|
Loading…
Reference in a new issue