]> source.dussan.org Git - nextcloud-server.git/commitdiff
Expose the info to the JS
authorRoeland Jago Douma <roeland@famdouma.nl>
Fri, 2 Nov 2018 11:32:45 +0000 (12:32 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Fri, 2 Nov 2018 12:44:45 +0000 (13:44 +0100)
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
lib/private/Template/JSConfigHelper.php

index ad9ff0b6757e84d7526c32f77243f88e6851645c..26da8fcc3c9c740ce5d64367d33ab9dce4ff3b12 100644 (file)
@@ -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