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

don't blame randome people for background email updates #10687

Merged
merged 3 commits into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
27 changes: 19 additions & 8 deletions apps/admin_audit/lib/Actions/UserManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,25 @@ public function unassign(string $uid) {
* @param array $params
*/
public function change(array $params) {
if ($params['feature'] === 'enabled') {
$this->log(
$params['value'] === 'true' ? 'User enabled: "%s"' : 'User disabled: "%s"',
['user' => $params['user']->getUID()],
[
'user',
]
);
switch($params['feature']) {
case 'enabled':
$this->log(
$params['value'] === 'true' ? 'User enabled: "%s"' : 'User disabled: "%s"',
['user' => $params['user']->getUID()],
[
'user',
]
);
break;
case 'eMailAddress':
$this->log(
'Email address changed for user %s',
['user' => $params['user']->getUID()],
[
'user',
]
);
break;
}
}

Expand Down
13 changes: 5 additions & 8 deletions settings/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public function onChangeEmail(IUser $user, $oldMailAddress) {

$actor = $this->userSession->getUser();
if ($actor instanceof IUser) {
$subject = Provider::EMAIL_CHANGED_SELF;
if ($actor->getUID() !== $user->getUID()) {
$this->l = $this->languageFactory->get(
'settings',
Expand All @@ -173,15 +174,11 @@ public function onChangeEmail(IUser $user, $oldMailAddress) {
$this->config->getSystemValue('default_language', 'en')
)
);

$text = $this->l->t('%1$s changed your email address on %2$s.', [$actor->getDisplayName(), $instanceUrl]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is this case was there to notify you if an admin changed your e-mail... right?

Copy link
Member Author

@blizzz blizzz Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, that's further below. Though i don't know what that works at it checks the user who is logged in. But it works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one below is for the CLI change. That one here is for all web based accesses.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was for admin cases where its done via the UI. So you know whome to contact if someone changes your details.

The admin strings below are for not logged in users, aka CLI commands.

$event->setAuthor($actor->getUID())
->setSubject(Provider::EMAIL_CHANGED_BY, [$actor->getUID()]);
} else {
$text = $this->l->t('Your email address on %s was changed.', [$instanceUrl]);
$event->setAuthor($actor->getUID())
->setSubject(Provider::EMAIL_CHANGED_SELF);
$subject = Provider::EMAIL_CHANGED;
}
$text = $this->l->t('Your email address on %s was changed.', [$instanceUrl]);
$event->setAuthor($actor->getUID())
->setSubject($subject);
} else {
$text = $this->l->t('Your email address on %s was changed by an administrator.', [$instanceUrl]);
$event->setSubject(Provider::EMAIL_CHANGED);
Expand Down