diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-04-24 12:20:01 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-04-28 23:41:36 -0300 |
commit | 391a989a911befd9dba6318b40234f63bbd15db0 (patch) | |
tree | 57cdd442cfb371524db5be4d4fa1f33754a16236 /lib/private/Accounts | |
parent | f3c433af7bd2aad6dbae2de55be53b2267be759b (diff) | |
download | nextcloud-server-391a989a911befd9dba6318b40234f63bbd15db0.tar.gz nextcloud-server-391a989a911befd9dba6318b40234f63bbd15db0.zip |
make sure that every data set has a 'verified' status
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib/private/Accounts')
-rw-r--r-- | lib/private/Accounts/AccountManager.php | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index cc65ae8caa1..3f4b1d9d79a 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -134,7 +134,11 @@ class AccountManager { return $userData; } - return json_decode($result[0]['data'], true); + $userDataArray = json_decode($result[0]['data'], true); + + $userDataArray = $this->addMissingDefaultValues($userDataArray); + + return $userDataArray; } /** @@ -160,6 +164,23 @@ class AccountManager { } /** + * make sure that all expected data are set + * + * @param array $userData + * @return array + */ + protected function addMissingDefaultValues(array $userData) { + + foreach ($userData as $key => $value) { + if (!isset($userData[$key]['verified'])) { + $userData[$key]['verified'] = self::NOT_VERIFIED; + } + } + + return $userData; + } + + /** * reset verification status if personal data changed * * @param array $oldData @@ -190,19 +211,19 @@ class AccountManager { if($twitterVerified && $oldData[self::PROPERTY_TWITTER]['value'] !== $newData[self::PROPERTY_TWITTER]['value'] ) { - $newData[self::PROPERTY_TWITTER]['value']['verified'] = self::NOT_VERIFIED; + $newData[self::PROPERTY_TWITTER]['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; + $newData[self::PROPERTY_WEBSITE]['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; + $newData[self::PROPERTY_EMAIL]['verified'] = self::NOT_VERIFIED; } return $newData; @@ -263,19 +284,19 @@ class AccountManager { [ 'value' => '', 'scope' => self::VISIBILITY_PRIVATE, - 'verified' => '0', + 'verified' => self::NOT_VERIFIED, ], self::PROPERTY_WEBSITE => [ 'value' => '', 'scope' => self::VISIBILITY_PRIVATE, - 'verified' => '0', + 'verified' => self::NOT_VERIFIED, ], self::PROPERTY_EMAIL => [ 'value' => $user->getEMailAddress(), 'scope' => self::VISIBILITY_CONTACTS_ONLY, - 'verified' => '0', + 'verified' => self::NOT_VERIFIED, ], self::PROPERTY_AVATAR => [ @@ -285,13 +306,13 @@ class AccountManager { [ 'value' => '', 'scope' => self::VISIBILITY_PRIVATE, - 'verified' => '0', + 'verified' => self::NOT_VERIFIED, ], self::PROPERTY_TWITTER => [ 'value' => '', 'scope' => self::VISIBILITY_PRIVATE, - 'verified' => '0', + 'verified' => self::NOT_VERIFIED, ], ]; } |