keycloak-uncached

KEYCLOAK-667 Remove client-side idle timeout from admin console

9/9/2014 5:44:08 AM

Details

diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/index.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/index.html
index 006fe1c..3e50295 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/index.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/index.html
@@ -17,8 +17,6 @@
     <script src="lib/angular/angular-route.js"></script>
     <script src="lib/angular/ui-bootstrap-tpls-0.11.0.js"></script>
 
-    <script src="lib/jquery/jquery.idletimer.js" type="text/javascript"></script>
-    <script src="lib/jquery/jquery.idletimeout.js" type="text/javascript"></script>
     <script src="lib/angular/select2.js" type="text/javascript"></script>
     <script src="lib/fileupload/angular-file-upload.min.js"></script>
     <script src="lib/filesaver/FileSaver.js"></script>
@@ -75,28 +73,5 @@
     </div>
 </div>
 
-<script type="text/javascript">
-    $.idleTimeout('#idletimeout', '#idletimeout a', {
-        idleAfter: 300,
-        pollingInterval: 60,
-//        keepAliveURL: authUrl + '/admin/keepalive', would need to change this path
-        serverResponseEquals: '',
-        failedRequests: 1,
-        onTimeout: function(){
-            $(this).slideUp();
-            logout();
-        },
-        onIdle: function(){
-            $(this).slideDown(); // show the warning bar
-        },
-        onCountdown: function( counter ){
-            $(this).find("span").html( counter ); // update the counter
-        },
-        onResume: function(){
-            $(this).slideUp(); // hide the warning bar
-        }
-    });
-</script>
-
 </body>
 </html>
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/app.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/app.js
index c203d39..0ac9abd 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/app.js
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/app.js
@@ -4,17 +4,9 @@ var consoleBaseUrl = window.location.href;
 consoleBaseUrl = consoleBaseUrl.substring(0, consoleBaseUrl.indexOf("/console"));
 consoleBaseUrl = consoleBaseUrl + "/console";
 var configUrl = consoleBaseUrl + "/config";
-var logoutUrl = consoleBaseUrl + "/logout";
-var auth = {};
-var logout = function(){
-    console.log('*** LOGOUT');
-    window.location = logoutUrl;
-};
-
-
-var authUrl = window.location.href;
-authUrl = authUrl.substring(0, authUrl.indexOf('/admin/'));
 
+var auth = {};
+var authUrl = window.location.href.substring(0, window.location.href.indexOf('/admin/'));
 
 var module = angular.module('keycloak', [ 'keycloak.services', 'keycloak.loaders', 'ui.bootstrap', 'ui.select2', 'angularFileUpload' ]);
 var resourceRequests = 0;
@@ -803,14 +795,13 @@ module.config(function($httpProvider) {
 
 });
 
-module.factory('errorInterceptor', function($q, $window, $rootScope, $location,Notifications) {
+module.factory('errorInterceptor', function($q, $window, $rootScope, $location, Notifications, Auth) {
     return function(promise) {
         return promise.then(function(response) {
             return response;
         }, function(response) {
             if (response.status == 401) {
-                console.log('session timeout?');
-                logout();
+                Auth.authz.logout();
              } else if (response.status == 403) {
                 Notifications.error("Forbidden");
             } else if (response.status == 404) {
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/realm.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/realm.js
index f7d6fba..4412441 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/realm.js
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/realm.js
@@ -4,8 +4,6 @@ module.controller('GlobalCtrl', function($scope, $http, Auth, WhoAmI, Current, $
     };
 
     $scope.authUrl = authUrl;
-    $scope.logout = logout;
-
     $scope.auth = Auth;
 
     WhoAmI.get(function (data) {
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/menu.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/menu.html
index 03830e9..13e4ea1 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/menu.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/menu.html
@@ -20,7 +20,7 @@
 		                </a>
 		                <ul class="dropdown-menu">
 		                    <li><a href="{{authUrl}}/realms/{{auth.user.realm}}/account?referrer=security-admin-console">Manage Account</a></li>
-		                    <li class="separator"><a href="" ng-click="logout()">Sign Out</a></li>
+		                    <li class="separator"><a href="" ng-click="auth.authz.logout()">Sign Out</a></li>
 		                </ul>
 		            </li>
 		        </ul>