Sorry for the dumb question prior to actually inspecting the code -- I see that
the system is configured so that it's supposed to do this! However, it does not
work when using an external auth (in my case, IMAP).
The problem is that the 'email' field of the oc_accounts table is not
populated, nor can it be set by the user. Additionally, a success message is
displayed if the user attempts to change the email address, even though it does
not take effect, due to an error in unchecked return types.
I've attached a patch that fixes the lack of an error message, but not one that
addresses the underlying problem as I don't understand the system architecture
well. It appears that the reason setting the address fails is because the user
is not given permissions to edit their account (by the GroupManager object)
when the backend is IMAP. I'm not sure the right way to go about fixing this
problem.
Regards,
--Jered
--- UsersController.php 2018/01/28 12:15:31 1.1
+++ UsersController.php 2018/01/28 12:59:22
@@ -35,7 +35,6 @@
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;
@@ -600,21 +599,21 @@
);
}
- // admins can set email without verification
- if ($mailAddress === '' || $this->isAdmin) {
- $this->setEmailAddress($userId, $mailAddress);
- return new DataResponse(
- [
- 'status' => 'success',
- 'data' => [
- 'message' => (string)$this->l10n->t('Email has been changed successfully.')
- ]
- ],
- Http::STATUS_OK
- );
- }
-
try {
+ // admins can set email without verification
+ if ($mailAddress === '' || $this->isAdmin) {
+ $this->setEmailAddress($userId, $mailAddress);
+ return new DataResponse(
+ [
+ 'status' => 'success',
+ 'data' => [
+ 'message' => (string)$this->l10n->t('Email has been changed successfully.')
+ ]
+ ],
+ Http::STATUS_OK
+ );
+ }
+
if ($this->sendEmail($userId, $mailAddress)) {
return new DataResponse(
[
@@ -794,6 +793,7 @@
*
* @param string $id
* @param string $mailAddress
+ * @throws \Exception
*/
public function setEmailAddress($id, $mailAddress) {
$user = $this->userManager->get($id);
@@ -805,10 +805,9 @@
$this->config->deleteUserValue($id, 'owncloud', 'changeMail');
}
} else {
- return new JSONResponse([
- 'error' => 'cannotSetEmailAddress',
- 'message' => 'Cannot set email address for user'
- ], HTTP::STATUS_NOT_FOUND);
+ throw new \Exception($this->l10n->t(
+ 'Cannot set email address for user.'
+ ));
}
}
@@ -843,7 +842,12 @@
$splittedToken = explode(':', $this->config->getUserValue($userId, 'owncloud',
'changeMail', null));
$mailAddress = $splittedToken[2];
- $this->setEmailAddress($userId, $mailAddress);
+ try {
+ $this->setEmailAddress($userId, $mailAddress);
+ } catch (\Exception $e) {
+ $this->log->error($e->getMessage(), ['app' => 'settings']);
+ return new
RedirectResponse($this->urlGenerator->linkToRoute('settings.SettingsPage.getPersonal',
['changestatus' => 'error']));
+ }
if ($oldEmailAddress !== null && $oldEmailAddress !== '') {
$tmpl = new \OC_Template('settings', 'changemail/notify');
----- On Jan 26, 2018, at 2:53 PM, Jered Floyd <[email protected]> wrote:
OwnCloud Community,
Is there any way to configure OwnCloud to send the email notifications of
external shares with a "From:" address of the sharing user, rather than an
owncloud administrative address? Or, at least, a "Reply-To"? I get constant
replies from outside users meaning to reply to the sharing user.
Thanks,
--Jered
_______________________________________________
User mailing list
[email protected]
http://mailman.owncloud.org/mailman/listinfo/user
_______________________________________________
User mailing list
[email protected]
http://mailman.owncloud.org/mailman/listinfo/user