diff options
Diffstat (limited to 'testapi/opnfv_testapi/ui/app.js')
-rw-r--r-- | testapi/opnfv_testapi/ui/app.js | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/testapi/opnfv_testapi/ui/app.js b/testapi/opnfv_testapi/ui/app.js index 34ac7ef..c2fa774 100644 --- a/testapi/opnfv_testapi/ui/app.js +++ b/testapi/opnfv_testapi/ui/app.js @@ -154,6 +154,7 @@ function setup($http, $rootScope, $window, $state, testapiApiUrl, authenticate) { $rootScope.auth = {}; + $rootScope.authenticate = authenticate $rootScope.auth.doSignIn = doSignIn; $rootScope.auth.doSignOut = doSignOut; $rootScope.auth.doSignCheck = doSignCheck; @@ -170,10 +171,14 @@ /** This function will initate a sign out. */ function doSignOut() { - $rootScope.auth.currentUser = null; - $rootScope.auth.isAuthenticated = false; - $rootScope.auth.projectNames = []; - $window.location.href = sign_out_url; + if(authenticate){ + $rootScope.auth.currentUser = null; + $rootScope.auth.isAuthenticated = false; + $rootScope.auth.projectNames = []; + $window.location.href = sign_out_url; + }else{ + $state.go("home", {reload: true}) + } } /** @@ -181,21 +186,23 @@ * authenticated. */ function doSignCheck() { - return $http.get(profile_url, {withCredentials: true}). - success(function (data) { - $rootScope.auth.currentUser = data; - $rootScope.auth.isAuthenticated = true; - if(authenticate){ + if(authenticate){ + return $http.get(profile_url, {withCredentials: true}). + success(function (data) { + $rootScope.auth.currentUser = data; + $rootScope.auth.isAuthenticated = true; $rootScope.auth.projectNames = $rootScope.auth.doSubmitterCheck(data.groups); - }else{ - $rootScope.auth.projectNames = ["anonymous"] - } - }). - error(function () { - $rootScope.auth.currentUser = null; - $rootScope.auth.isAuthenticated = false; - $rootScope.auth.projectNames = []; - }); + }). + error(function () { + $rootScope.auth.currentUser = null; + $rootScope.auth.isAuthenticated = false; + $rootScope.auth.projectNames = []; + }); + }else{ + $rootScope.auth.currentUser = null; + $rootScope.auth.isAuthenticated = true; + $rootScope.auth.projectNames = [] + } } function doSubmitterCheck(groups){ |