Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2021-05-13 00:35:39 +0300
committerGitHub <noreply@github.com>2021-05-13 00:35:39 +0300
commitb8b2e796bfc604c36aed83fc6e8c509cac92ca26 (patch)
treef85a832bb2c757a795cca1461d2d9250b9a3490c
parenta923213b4f09e979fff224b306bec13f0a863dba (diff)
parent99770273217f63840d76c04545bd758eb63690ba (diff)
Merge pull request #26959 from nextcloud/techdebt/noid/verifiyuserdata-iaccountmanager
VerifyUserData shall use IAccountManager, not private API
-rw-r--r--apps/settings/lib/BackgroundJobs/VerifyUserData.php59
1 files changed, 29 insertions, 30 deletions
diff --git a/apps/settings/lib/BackgroundJobs/VerifyUserData.php b/apps/settings/lib/BackgroundJobs/VerifyUserData.php
index 9e99f3a0ad7..ee1cc43c53b 100644
--- a/apps/settings/lib/BackgroundJobs/VerifyUserData.php
+++ b/apps/settings/lib/BackgroundJobs/VerifyUserData.php
@@ -30,8 +30,8 @@
namespace OCA\Settings\BackgroundJobs;
-use OC\Accounts\AccountManager;
use OCP\Accounts\IAccountManager;
+use OCP\Accounts\PropertyDoesNotExistException;
use OCP\AppFramework\Http;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
@@ -52,7 +52,7 @@ class VerifyUserData extends Job {
/** @var int how much time should be between two tries (1 hour) */
private $interval = 3600;
- /** @var AccountManager */
+ /** @var IAccountManager */
private $accountManager;
/** @var IUserManager */
@@ -70,7 +70,7 @@ class VerifyUserData extends Job {
/** @var IConfig */
private $config;
- public function __construct(AccountManager $accountManager,
+ public function __construct(IAccountManager $accountManager,
IUserManager $userManager,
IClientService $clientService,
ILogger $logger,
@@ -157,28 +157,19 @@ class VerifyUserData extends Job {
$this->logger->error($argument['uid'] . ' doesn\'t exist, can\'t verify user data.');
return $result;
}
- $userData = $this->accountManager->getUser($user);
-
- if ($publishedCodeSanitized === $argument['verificationCode']) {
- $userData[IAccountManager::PROPERTY_WEBSITE]['verified'] = AccountManager::VERIFIED;
- } else {
- $userData[IAccountManager::PROPERTY_WEBSITE]['verified'] = AccountManager::NOT_VERIFIED;
- }
-
- $this->accountManager->updateUser($user, $userData);
+ $userAccount = $this->accountManager->getAccount($user);
+ $websiteProp = $userAccount->getProperty(IAccountManager::PROPERTY_WEBSITE);
+ $websiteProp->setVerified($publishedCodeSanitized === $argument['verificationCode']
+ ? IAccountManager::VERIFIED
+ : IAccountManager::NOT_VERIFIED
+ );
+ $this->accountManager->updateAccount($userAccount);
}
return $result;
}
- /**
- * verify email address
- *
- * @param array $argument
- * @param string $dataType
- * @return bool true if we could check the verification code, otherwise false
- */
- protected function verifyViaLookupServer(array $argument, $dataType) {
+ protected function verifyViaLookupServer(array $argument, string $dataType): bool {
if (empty($this->lookupServerUrl) ||
$this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes') !== 'yes' ||
$this->config->getSystemValue('has_internet_connection', true) === false) {
@@ -193,10 +184,7 @@ class VerifyUserData extends Job {
return true;
}
- $localUserData = $this->accountManager->getUser($user);
$cloudId = $user->getCloudId();
-
- // ask lookup-server for user data
$lookupServerData = $this->queryLookupServer($cloudId);
// for some reasons we couldn't read any data from the lookup server, try again later
@@ -210,12 +198,18 @@ class VerifyUserData extends Job {
}
// lookup server hasn't verified the email address so far, try again later
- if ($lookupServerData[$dataType]['verified'] === AccountManager::NOT_VERIFIED) {
+ if ($lookupServerData[$dataType]['verified'] === IAccountManager::NOT_VERIFIED) {
return false;
}
- $localUserData[$dataType]['verified'] = AccountManager::VERIFIED;
- $this->accountManager->updateUser($user, $localUserData);
+ try {
+ $userAccount = $this->accountManager->getAccount($user);
+ $property = $userAccount->getProperty($dataType);
+ $property->setVerified(IAccountManager::VERIFIED);
+ $this->accountManager->updateAccount($userAccount);
+ } catch (PropertyDoesNotExistException $e) {
+ return false;
+ }
return true;
}
@@ -281,12 +275,17 @@ class VerifyUserData extends Job {
/**
* reset verification state after max tries are reached
*/
- protected function resetVerificationState() {
+ protected function resetVerificationState(): void {
$user = $this->userManager->get($this->argument['uid']);
if ($user !== null) {
- $accountData = $this->accountManager->getUser($user);
- $accountData[$this->argument['type']]['verified'] = AccountManager::NOT_VERIFIED;
- $this->accountManager->updateUser($user, $accountData);
+ $userAccount = $this->accountManager->getAccount($user);
+ try {
+ $property = $userAccount->getProperty($this->argument['type']);
+ $property->setVerified(IAccountManager::NOT_VERIFIED);
+ $this->accountManager->updateAccount($userAccount);
+ } catch (PropertyDoesNotExistException $e) {
+ return;
+ }
}
}
}