Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stable10] Fix for subadmins edit email address of its users #28366

Merged
merged 1 commit into from
Jul 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions settings/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Utility\ITimeFactory;
Expand Down Expand Up @@ -789,15 +790,25 @@ public function sendEmail($userId, $mailAddress) {
}

/**
* @NoAdminRequired
*
* @param string $id
* @param string $mailAddress
*/
public function setEmailAddress($id, $mailAddress) {
$user = $this->userManager->get($id);

$user->setEMailAddress($mailAddress);
if ($this->config->getUserValue($id, 'owncloud', 'changeMail') !== '') {
$this->config->deleteUserValue($id, 'owncloud', 'changeMail');
if($this->isAdmin ||
($this->groupManager->getSubAdmin()->isSubAdmin($this->userSession->getUser()) &&
$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user))) {
$user->setEMailAddress($mailAddress);
if ($this->config->getUserValue($id, 'owncloud', 'changeMail') !== '') {
$this->config->deleteUserValue($id, 'owncloud', 'changeMail');
}
} else {
return new JSONResponse([
'error' => 'cannotSetEmailAddress',
'message' => 'Cannot set email address for user'
], HTTP::STATUS_NOT_FOUND);
}
}

Expand Down