From c232c17b710334ba3a50c92a7f4004d5aad9cddd Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 12 Nov 2021 14:35:15 -0800 Subject: [PATCH] GUACAMOLE-680: Navigate user back to home screen upon clicking "re-login". --- .../app/index/controllers/indexController.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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 4d3bf9b73..77f67db2f 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 const $document = $injector.get('$document'); + const $location = $injector.get('$location'); const $route = $injector.get('$route'); const $window = $injector.get('$window'); const clipboardService = $injector.get('clipboardService'); @@ -220,13 +221,22 @@ angular.module('index').controller('indexController', ['$scope', '$injector', }, true); /** - * Reloads the current route and controller, effectively forcing - * reauthentication. If the user is not logged in, this will result in - * the login screen appearing. + * Navigates the user back to the root of the application (or reloads the + * current route and controller if the user is already there), effectively + * forcing reauthentication. If the user is not logged in, this will result + * in the login screen appearing. */ $scope.reAuthenticate = function reAuthenticate() { + $scope.reAuthenticating = true; - $route.reload(); + + // Clear out URL state to conveniently bring user back to home screen + // upon relogin + if ($location.path() !== '/') + $location.url('/'); + else + $route.reload(); + }; // Display login screen if a whole new set of credentials is needed