diff options
author | Emil Lundberg <emil@emlun.se> | 2023-10-15 14:10:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-15 14:10:41 +0200 |
commit | 14569f12d347a79025dced276d001e9f314d0afb (patch) | |
tree | 38338b21ffce365c30fed14f608f9052993d1c7f /gui | |
parent | a405c21ebba3e395a221d91e6654a269e83cdc02 (diff) | |
download | syncthing-14569f12d347a79025dced276d001e9f314d0afb.tar.gz syncthing-14569f12d347a79025dced276d001e9f314d0afb.zip |
Hide log out button when auth is not enabled (#9158)
This was an oversight in #8757: the new "Log out" button is always shown
in the "Actions" menu, even when authentication is not enabled.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/default/index.html | 4 | ||||
-rwxr-xr-x | gui/default/syncthing/core/syncthingController.js | 12 |
2 files changed, 13 insertions, 3 deletions
diff --git a/gui/default/index.html b/gui/default/index.html index 0266da1a0..ea3dd0ebd 100644 --- a/gui/default/index.html +++ b/gui/default/index.html @@ -126,10 +126,12 @@ <li ng-if="authenticated" class="divider" aria-hidden="true"></li> <li ng-if="authenticated"><a href="" ng-click="advanced()"><span class="fa fa-fw fa-cogs"></span> <span translate>Advanced</span></a></li> <li ng-if="authenticated"><a href="" ng-click="logging.show()"><span class="fa fa-fw fa-wrench"></span> <span translate>Logs</span></a></li> - <li ng-if="authenticated"><a href="" ng-click="logout()"><span class="far fa-fw fa-ban"></span> <span translate>Log Out</span></a></li> <li class="divider" aria-hidden="true" ng-if="config.gui.debugging"></li> <li><a href="/rest/debug/support" target="_blank" ng-if="config.gui.debugging"><span class="fa fa-fw fa-user-md"></span> <span translate>Support Bundle</span></a></li> + + <li ng-if="authenticated && isAuthEnabled()" class="divider" aria-hidden="true"></li> + <li ng-if="authenticated && isAuthEnabled()"><a href="" ng-click="logout()"><span class="far fa-fw fa-sign-out"></span> <span translate>Log Out</span></a></li> </ul> </li> </ul> diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index 492e877c2..6b8180763 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -565,6 +565,15 @@ angular.module('syncthing.core') }).error($scope.emitHTTPError); } + $scope.isAuthEnabled = function () { + // This function should match IsAuthEnabled() in guiconfiguration.go + var guiCfg = $scope.config && $scope.config.gui; + if (guiCfg) { + return guiCfg.authMode === 'ldap' || (guiCfg.user && guiCfg.password); + } + return false; + }; + function refreshNoAuthWarning() { if (!$scope.system || !$scope.config || !$scope.config.gui) { // We need all to be able to determine the state. @@ -579,8 +588,7 @@ angular.module('syncthing.core') $scope.openNoAuth = addr.substr(0, 4) !== "127." && addr.substr(0, 6) !== "[::1]:" && addr.substr(0, 1) !== "/" - && (!guiCfg.user || !guiCfg.password) - && guiCfg.authMode !== 'ldap' + && !$scope.isAuthEnabled() && !guiCfg.insecureAdminAccess; if ((guiCfg.user && guiCfg.password) || guiCfg.authMode === 'ldap') { |