summaryrefslogtreecommitdiffstats
path: root/lib/private/Accounts
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-03-23 16:06:57 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-04-28 23:41:36 -0300
commit6f41a3edc0bb7a297a28f3e5fa81fb68e3d71a1f (patch)
tree6934f8b244580a3daf8362d1bd76613d944bbedb /lib/private/Accounts
parentc9ccdca1ec2f586b8884b41a5319e4a908888df7 (diff)
downloadnextcloud-server-6f41a3edc0bb7a297a28f3e5fa81fb68e3d71a1f.tar.gz
nextcloud-server-6f41a3edc0bb7a297a28f3e5fa81fb68e3d71a1f.zip
store verification status in accounts table and update lookup server
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib/private/Accounts')
-rw-r--r--lib/private/Accounts/AccountManager.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php
index 2eb518d4f04..91be4be4ab7 100644
--- a/lib/private/Accounts/AccountManager.php
+++ b/lib/private/Accounts/AccountManager.php
@@ -53,6 +53,10 @@ class AccountManager {
const PROPERTY_ADDRESS = 'address';
const PROPERTY_TWITTER = 'twitter';
+ const NOT_VERIFIED = '0';
+ const VERIFICATION_IN_PROGRESS = '1';
+ const VERIFIED = '2';
+
/** @var IDBConnection database connection */
private $connection;
@@ -85,6 +89,7 @@ class AccountManager {
if (empty($userData)) {
$this->insertNewUser($user, $data);
} elseif ($userData !== $data) {
+ $data = $this->updateVerifyStatus($userData, $data);
$this->updateExistingUser($user, $data);
} else {
// nothing needs to be done if new and old data set are the same
@@ -124,6 +129,41 @@ class AccountManager {
}
/**
+ * reset verification status if personal data changed
+ *
+ * @param array $oldData
+ * @param array $newData
+ * @return array
+ */
+ protected function updateVerifyStatus($oldData, $newData) {
+
+ $twitterVerified = isset($oldData[self::PROPERTY_TWITTER]['verified']) && $oldData[self::PROPERTY_TWITTER]['verified'] === self::VERIFIED;
+ $websiteVerified = isset($oldData[self::PROPERTY_WEBSITE]['verified']) && $oldData[self::PROPERTY_WEBSITE]['verified'] === self::VERIFIED;
+ $emailVerified = isset($oldData[self::PROPERTY_EMAIL]['verified']) && $oldData[self::PROPERTY_EMAIL]['verified'] === self::VERIFIED;
+
+ if($twitterVerified &&
+ $oldData[self::PROPERTY_TWITTER]['value'] !== $newData[self::PROPERTY_TWITTER]['value']
+ ) {
+ $newData[self::PROPERTY_TWITTER]['value']['verified'] = self::NOT_VERIFIED;
+ }
+
+ if($websiteVerified &&
+ $oldData[self::PROPERTY_WEBSITE]['value'] !== $newData[self::PROPERTY_WEBSITE]['value']
+ ) {
+ $newData[self::PROPERTY_WEBSITE]['value']['verified'] = self::NOT_VERIFIED;
+ }
+
+ if($emailVerified &&
+ $oldData[self::PROPERTY_EMAIL]['value'] !== $newData[self::PROPERTY_EMAIL]['value']
+ ) {
+ $newData[self::PROPERTY_EMAIL]['value']['verified'] = self::NOT_VERIFIED;
+ }
+
+ return $newData;
+
+ }
+
+ /**
* add new user to accounts table
*
* @param IUser $user
@@ -171,21 +211,25 @@ class AccountManager {
[
'value' => $user->getDisplayName(),
'scope' => self::VISIBILITY_CONTACTS_ONLY,
+ 'verified' => '0',
],
self::PROPERTY_ADDRESS =>
[
'value' => '',
'scope' => self::VISIBILITY_PRIVATE,
+ 'verified' => '0',
],
self::PROPERTY_WEBSITE =>
[
'value' => '',
'scope' => self::VISIBILITY_PRIVATE,
+ 'verified' => '0',
],
self::PROPERTY_EMAIL =>
[
'value' => $user->getEMailAddress(),
'scope' => self::VISIBILITY_CONTACTS_ONLY,
+ 'verified' => '0',
],
self::PROPERTY_AVATAR =>
[
@@ -195,11 +239,13 @@ class AccountManager {
[
'value' => '',
'scope' => self::VISIBILITY_PRIVATE,
+ 'verified' => '0',
],
self::PROPERTY_TWITTER =>
[
'value' => '',
'scope' => self::VISIBILITY_PRIVATE,
+ 'verified' => '0',
],
];
}