array('message' => 'Authentication error'))); exit(); } if (\OCP\App::isEnabled('files_encryption') && $userstatus !== 'user') { $util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), $username); $recoveryAdminEnabled = OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled'); $recoveryEnabledForUser = $util->recoveryEnabledForUser(); if ($recoveryAdminEnabled && $recoveryEnabledForUser && $recoveryPassword === '') { OC_JSON::error(array('data' => array('message' => 'Please provide a admin recovery password, otherwise all user data will be lost'))); } elseif ($recoveryPassword && !$util->checkRecoveryPassword($recoveryPassword)) { OC_JSON::error(array('data' => array('message' => 'Wrong admin recovery password. Please check the password and try again.'))); } elseif (!is_null($password) && OC_User::setPassword($username, $password, $recoveryPassword)) { OC_JSON::success(array('data' => array('username' => $username))); } else { OC_JSON::error(array('data' => array('message' => 'Unable to change password'))); } } else { if (!is_null($password) && OC_User::setPassword($username, $password)) { OC_JSON::success(array('data' => array('username' => $username))); } else { OC_JSON::error(array('data' => array('message' => 'Unable to change password'))); } }