1app.factory('Auth', ['$http', '$rootScope', '$window', 'AUTH_EVENTS', '$state', '$location', 2 function($http, $rootScope, $window, AUTH_EVENTS, $state, $location) { 3 var contextPath = window.location.pathname.substring(0, window.location.pathname.indexOf("/",2)); 4 var authService = {}; 5 //the login function 6 authService.login = function(user, success, error) { 7 keycloak.init({ 8 onLoad: 'login-required', 9 checkLoginIframe: false 10 }).then(auth => { 11 if (auth) { 12 sessionStorage.leId = $rootScope.currentUser.entityId; 13 sessionStorage.userId = $rootScope.currentUser.userId; 14 if (keycloak.token && ($rootScope.currentUser != undefined || $rootScope.currentUser != null)) { 15 $rootScope 16 .$broadcast(AUTH_EVENTS.loginSuccess); 17 $rootScope.loadingApplication = false; 18 $rootScope.$apply(); 19 console.log("loadingApplication ::",$rootScope.loadingApplication); 20 } else { 21 $rootScope 22 .$broadcast(AUTH_EVENTS.loginFailed); 23 } 24 } 25 }); 26 keycloak.onTokenExpired = () => { 27 console.log('token expired', new Date()); 28 keycloak.updateToken(30).then(() => { 29 console.log('token refreshed'); 30 }).error(() => { console.error("Failed to fetch token") }); 31 } 32 }; 33 //log out the user and broadcast the logoutSuccess event 34 authService.logout = function() { 35 window.location.href = contextPath+"/logout"; 36 sessionStorage.authToken=null; 37 } 38 39 return authService; 40 } 41 ]); 42
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.