From 823970eb7f62d20eb29248eb41ee1b6831c2b7a9 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 13 Jun 2021 21:25:37 -0700 Subject: [PATCH] GUACAMOLE-680: Display status message upon logout (rather than immediately reauthenticating). The former behavior (immediately reauthenticating) typically results in the login screen appearing, but will also instantly sign the user back in if a single sign-on solution is being used. This results in the logout action appearing to have no effect when SSO is involved. --- .../client/controllers/clientController.js | 5 +--- .../app/index/controllers/indexController.js | 20 ++++++++++++++++ .../src/app/index/styles/logged-out.css | 23 +++++++++++++++++++ .../app/navigation/directives/guacUserMenu.js | 8 +------ guacamole/src/main/frontend/src/index.html | 11 +++++++++ .../main/frontend/src/translations/en.json | 2 ++ 6 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 guacamole/src/main/frontend/src/app/index/styles/logged-out.css diff --git a/guacamole/src/main/frontend/src/app/client/controllers/clientController.js b/guacamole/src/main/frontend/src/app/client/controllers/clientController.js index 782167614..1bc5dd6fa 100644 --- a/guacamole/src/main/frontend/src/app/client/controllers/clientController.js +++ b/guacamole/src/main/frontend/src/app/client/controllers/clientController.js @@ -167,10 +167,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams className : "logout button", callback : function logoutCallback() { authenticationService.logout() - ['catch'](requestService.IGNORE) - ['finally'](function logoutComplete() { - $location.url('/'); - }); + ['catch'](requestService.IGNORE); } }; diff --git a/guacamole/src/main/frontend/src/app/index/controllers/indexController.js b/guacamole/src/main/frontend/src/app/index/controllers/indexController.js index 532f0db65..51f129a3f 100644 --- a/guacamole/src/main/frontend/src/app/index/controllers/indexController.js +++ b/guacamole/src/main/frontend/src/app/index/controllers/indexController.js @@ -25,6 +25,7 @@ angular.module('index').controller('indexController', ['$scope', '$injector', // Required services var $document = $injector.get('$document'); + var $route = $injector.get('$route'); var $window = $injector.get('$window'); var clipboardService = $injector.get('clipboardService'); var guacNotification = $injector.get('guacNotification'); @@ -50,6 +51,13 @@ angular.module('index').controller('indexController', ['$scope', '$injector', */ $scope.loginHelpText = null; + /** + * Whether the user has selected to log back in after having logged out. + * + * @type boolean + */ + $scope.reAuthenticating = false; + /** * The credentials that the authentication service is has already accepted, * pending additional credentials, if any. If the user is logged in, or no @@ -94,6 +102,11 @@ angular.module('index').controller('indexController', ['$scope', '$injector', */ LOADING : 'loading', + /** + * The user has manually logged out. + */ + LOGGED_OUT : 'loggedOut', + /** * The application has fully loaded and the user has logged in */ @@ -256,6 +269,13 @@ angular.module('index').controller('indexController', ['$scope', '$injector', }); + // Replace the overall user interface with an informational message if the + // user has manually logged out + $scope.$on('guacLogout', function loggedOut() { + $scope.applicationState = ApplicationState.LOGGED_OUT; + $scope.reAuthenticating = false; + }); + // Ensure new pages always start with clear keyboard state $scope.$on('$routeChangeStart', function routeChanging() { keyboard.reset(); diff --git a/guacamole/src/main/frontend/src/app/index/styles/logged-out.css b/guacamole/src/main/frontend/src/app/index/styles/logged-out.css new file mode 100644 index 000000000..89f02c09d --- /dev/null +++ b/guacamole/src/main/frontend/src/app/index/styles/logged-out.css @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +.logged-out-modal guac-modal { + background: white; + z-index: 20; +} diff --git a/guacamole/src/main/frontend/src/app/navigation/directives/guacUserMenu.js b/guacamole/src/main/frontend/src/app/navigation/directives/guacUserMenu.js index c6630e72b..44a2fb5a7 100644 --- a/guacamole/src/main/frontend/src/app/navigation/directives/guacUserMenu.js +++ b/guacamole/src/main/frontend/src/app/navigation/directives/guacUserMenu.js @@ -140,13 +140,7 @@ angular.module('navigation').directive('guacUserMenu', [function guacUserMenu() */ $scope.logout = function logout() { authenticationService.logout() - ['catch'](requestService.IGNORE) - ['finally'](function logoutComplete() { - if ($location.path() !== '/') - $location.url('/'); - else - $route.reload(); - }); + ['catch'](requestService.IGNORE); }; /** diff --git a/guacamole/src/main/frontend/src/index.html b/guacamole/src/main/frontend/src/index.html index e8dbdb82a..01ae99ac4 100644 --- a/guacamole/src/main/frontend/src/index.html +++ b/guacamole/src/main/frontend/src/index.html @@ -40,6 +40,17 @@ + +
+ +

+

+ +

+
+
+
diff --git a/guacamole/src/main/frontend/src/translations/en.json b/guacamole/src/main/frontend/src/translations/en.json index f75914973..191921a80 100644 --- a/guacamole/src/main/frontend/src/translations/en.json +++ b/guacamole/src/main/frontend/src/translations/en.json @@ -15,6 +15,7 @@ "ACTION_DELETE_SESSIONS" : "Kill Sessions", "ACTION_DOWNLOAD" : "Download", "ACTION_LOGIN" : "Login", + "ACTION_LOGIN_AGAIN" : "Re-login", "ACTION_LOGOUT" : "Logout", "ACTION_MANAGE_CONNECTIONS" : "Connections", "ACTION_MANAGE_PREFERENCES" : "Preferences", @@ -44,6 +45,7 @@ "FORMAT_DATE_TIME_PRECISE" : "yyyy-MM-dd HH:mm:ss", "INFO_ACTIVE_USER_COUNT" : "Currently in use by {USERS} {USERS, plural, one{user} other{users}}.", + "INFO_LOGGED_OUT" : "You have been logged out.", "TEXT_ANONYMOUS_USER" : "Anonymous", "TEXT_HISTORY_DURATION" : "{VALUE} {UNIT, select, second{{VALUE, plural, one{second} other{seconds}}} minute{{VALUE, plural, one{minute} other{minutes}}} hour{{VALUE, plural, one{hour} other{hours}}} day{{VALUE, plural, one{day} other{days}}} other{}}",