diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-23 13:05:01 +0100 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-23 20:19:31 +0100 |
commit | 546989959c11bc773461cdd8ff0233e3f54255e0 (patch) | |
tree | 5d0a21d29ddb848eb27e4f8ce090a942c7412fb6 /settings | |
parent | f692ea34f1f1ce128ad40e3bf248c6342260c6c1 (diff) | |
download | nextcloud-server-546989959c11bc773461cdd8ff0233e3f54255e0.tar.gz nextcloud-server-546989959c11bc773461cdd8ff0233e3f54255e0.zip |
update email address correctly
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'settings')
-rw-r--r-- | settings/Controller/UsersController.php | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/settings/Controller/UsersController.php b/settings/Controller/UsersController.php index 206f1872542..42d464c961a 100644 --- a/settings/Controller/UsersController.php +++ b/settings/Controller/UsersController.php @@ -536,7 +536,6 @@ class UsersController extends Controller { $twitterScope ) { - if(!empty($email) && !$this->mailer->validateMailAddress($email)) { return new DataResponse( array( @@ -549,8 +548,6 @@ class UsersController extends Controller { ); } - $user = $this->userSession->getUser(); - $data = [ AccountManager::PROPERTY_AVATAR => ['scope' => $avatarScope], AccountManager::PROPERTY_DISPLAYNAME => ['value' => $displayname, 'scope' => $displaynameScope], @@ -561,7 +558,7 @@ class UsersController extends Controller { AccountManager::PROPERTY_TWITTER => ['value' => $twitter, 'scope' => $twitterScope] ]; - $this->accountManager->updateUser($user, $data); + $user = $this->userSession->getUser(); try { $this->saveUserSettings($user, $data); @@ -603,20 +600,25 @@ class UsersController extends Controller { * @param array $data * @throws ForbiddenException */ - private function saveUserSettings(IUser $user, $data) { + protected function saveUserSettings(IUser $user, $data) { // keep the user back-end up-to-date with the latest display name and email // address $oldDisplayName = $user->getDisplayName(); - if (isset($data[AccountManager::PROPERTY_DISPLAYNAME]['value']) && $oldDisplayName !== $data[AccountManager::PROPERTY_DISPLAYNAME]['value']) { + if (isset($data[AccountManager::PROPERTY_DISPLAYNAME]['value']) + && $oldDisplayName !== $data[AccountManager::PROPERTY_DISPLAYNAME]['value'] + ) { $result = $user->setDisplayName($data[AccountManager::PROPERTY_DISPLAYNAME]['value']); if ($result === false) { throw new ForbiddenException($this->l10n->t('Unable to change full name')); } } - if (isset($data['email'][0]['value']) && $user->getEMailAddress() !== $data['email'][0]['value']) { - $result = $user->setEMailAddress($data['email'][0]['value']); + $oldEmailAddress = $user->getEMailAddress(); + if (isset($data[AccountManager::PROPERTY_EMAIL]['value']) + && $oldEmailAddress !== $data[AccountManager::PROPERTY_EMAIL]['value'] + ) { + $result = $user->setEMailAddress($data[AccountManager::PROPERTY_EMAIL]['value']); if ($result === false) { throw new ForbiddenException($this->l10n->t('Unable to change mail address')); } |