diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-11-06 00:44:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-06 00:44:18 +0100 |
commit | 411d2dece5b65ac92f508189647df5bf03b005db (patch) | |
tree | 7a86213b522ee0ae970837e0b042b9b9585e5cfe /lib/private | |
parent | f350f2e3ec0bb9b06c7c585db0b9e33266f43021 (diff) | |
parent | 90c4b7db156c9aee6dc543032eabecc0b4364236 (diff) | |
download | nextcloud-server-411d2dece5b65ac92f508189647df5bf03b005db.tar.gz nextcloud-server-411d2dece5b65ac92f508189647df5bf03b005db.zip |
Merge pull request #11786 from nextcloud/feature/password_confirmation_backend
Expose password confirmation capabilities in the user backend
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php | 8 | ||||
-rw-r--r-- | lib/private/Template/JSConfigHelper.php | 13 | ||||
-rw-r--r-- | lib/private/User/User.php | 4 |
3 files changed, 22 insertions, 3 deletions
diff --git a/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php b/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php index 7c1c4595e9a..d752a68cf32 100644 --- a/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php @@ -29,6 +29,7 @@ use OCP\AppFramework\Middleware; use OCP\AppFramework\Utility\ITimeFactory; use OCP\ISession; use OCP\IUserSession; +use OCP\User\Backend\IPasswordConfirmationBackend; class PasswordConfirmationMiddleware extends Middleware { /** @var ControllerMethodReflector */ @@ -70,6 +71,13 @@ class PasswordConfirmationMiddleware extends Middleware { $user = $this->userSession->getUser(); $backendClassName = ''; if ($user !== null) { + $backend = $user->getBackend(); + if ($backend instanceof IPasswordConfirmationBackend) { + if (!$backend->canConfirmPassword($user->getUID())) { + return; + } + } + $backendClassName = $user->getBackendClassName(); } diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index ad9ff0b6757..26da8fcc3c9 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -37,6 +37,7 @@ use OCP\IL10N; use OCP\ISession; use OCP\IURLGenerator; use OCP\IUser; +use OCP\User\Backend\IPasswordConfirmationBackend; class JSConfigHelper { @@ -109,12 +110,18 @@ class JSConfigHelper { public function getConfig() { + $userBackendAllowsPasswordConfirmation = true; if ($this->currentUser !== null) { $uid = $this->currentUser->getUID(); - $userBackend = $this->currentUser->getBackendClassName(); + + $backend = $this->currentUser->getBackend(); + if ($backend instanceof IPasswordConfirmationBackend) { + $userBackendAllowsPasswordConfirmation = $backend->canConfirmPassword($uid); + } else if (isset($this->excludedUserBackEnds[$this->currentUser->getBackendClassName()])) { + $userBackendAllowsPasswordConfirmation = false; + } } else { $uid = null; - $userBackend = ''; } // Get the config @@ -161,7 +168,7 @@ class JSConfigHelper { $array = [ "oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false', "oc_isadmin" => $this->groupManager->isAdmin($uid) ? 'true' : 'false', - "backendAllowsPasswordConfirmation" => !isset($this->excludedUserBackEnds[$userBackend]) ? 'true' : 'false', + "backendAllowsPasswordConfirmation" => $userBackendAllowsPasswordConfirmation ? 'true' : 'false', "oc_dataURL" => is_string($dataLocation) ? "\"".$dataLocation."\"" : 'false', "oc_webroot" => "\"".\OC::$WEBROOT."\"", "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution diff --git a/lib/private/User/User.php b/lib/private/User/User.php index e171a65f8ce..06dd47b0887 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -302,6 +302,10 @@ class User implements IUser { return get_class($this->backend); } + public function getBackend() { + return $this->backend; + } + /** * check if the backend allows the user to change his avatar on Personal page * |