mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/LoginNotify
synced 2024-11-15 03:04:08 +00:00
Merge "Bundle notifications and show a single header message"
This commit is contained in:
commit
73adad2772
|
@ -57,10 +57,18 @@ class LoginNotifyHooks {
|
|||
'immediate' => true,
|
||||
];
|
||||
$notifications['login-fail-new'] = [
|
||||
'email-body-batch-message' => 'notification-loginnotify-login-fail-new-emailbatch'
|
||||
'email-body-batch-message' => 'notification-loginnotify-login-fail-new-emailbatch',
|
||||
'bundle' => [
|
||||
'web' => true,
|
||||
'expandable' => false
|
||||
]
|
||||
] + $loginBase;
|
||||
$notifications['login-fail-known'] = [
|
||||
'email-body-batch-message' => 'notification-loginnotify-login-fail-known-emailbatch'
|
||||
'email-body-batch-message' => 'notification-loginnotify-login-fail-known-emailbatch',
|
||||
'bundle' => [
|
||||
'web' => true,
|
||||
'expandable' => false
|
||||
]
|
||||
] + $loginBase;
|
||||
if ( $wgLoginNotifyEnableOnSuccess ) {
|
||||
$notificationCategories['login-success'] = [
|
||||
|
@ -79,6 +87,16 @@ class LoginNotifyHooks {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function onEchoGetBundleRules( $event, &$bundleString ) {
|
||||
switch ( $event->getType() ) {
|
||||
case 'login-fail-known':
|
||||
case 'login-fail-new':
|
||||
$bundleString = 'login-fail';
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Old hook for pre 1.27 or wikis with auth manager disabled.
|
||||
*
|
||||
|
|
|
@ -22,17 +22,22 @@ class LoginNotifyPresentationModel extends EchoEventPresentationModel {
|
|||
/**
|
||||
* Include the number of attempts in the message
|
||||
*
|
||||
* (For grep) This uses i18n messages:
|
||||
* notification-header-login-fail-known
|
||||
* notification-header-login-fail-new
|
||||
* notification-header-login-success
|
||||
*
|
||||
* @return Message
|
||||
*/
|
||||
public function getHeaderMessage() {
|
||||
return parent::getHeaderMessage()->numParams(
|
||||
$this->event->getExtraParam( 'count', 0 )
|
||||
);
|
||||
// Check if we got a bundled notification with a 'count' param
|
||||
// 'count' param is set when we have a failed login attempt
|
||||
if ( $this->isBundled() && ( $this->event->getExtraParam( 'count', 0 ) > 0 ) ) {
|
||||
$msg = $this->msg( 'notification-bundled-header-login-fail' );
|
||||
$msg->params( $this->event->getExtraParam( 'count', 0 ) );
|
||||
return $msg;
|
||||
} elseif ( $this->event->getExtraParam( 'count', 0 ) > 0 ) {
|
||||
$msg = $this->msg( 'notification-unbundled-header-login-fail' );
|
||||
return $msg;
|
||||
} else {
|
||||
$msg = $this->msg( 'notification-header-login-success' );
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
"BeforeCreateEchoEvent": [
|
||||
"LoginNotifyHooks::onBeforeCreateEchoEvent"
|
||||
],
|
||||
"EchoGetBundleRules": [
|
||||
"LoginNotifyHooks::onEchoGetBundleRules"
|
||||
],
|
||||
"LoginAuthenticateAudit": [
|
||||
"LoginNotifyHooks::onLoginAuthenticateAudit"
|
||||
],
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
"@metadata": {
|
||||
"authors": [
|
||||
"Brian Wolff",
|
||||
"MusikAnimal"
|
||||
"MusikAnimal",
|
||||
"Niharika"
|
||||
]
|
||||
},
|
||||
"loginnotify-desc": "Notify users about suspicious logins",
|
||||
|
@ -13,10 +14,10 @@
|
|||
"loginnotify-login-fail": "There have been several failed attempts to log in to your account",
|
||||
"notification-loginnotify-login-fail-email-subject": "{{PLURAL:$2|Failed attempt|Multiple failed attempts}} to log in to {{SITENAME}} as $1",
|
||||
"notification-loginnotify-login-success-email-subject": "Login to {{SITENAME}} as $1 from a computer you have not recently used",
|
||||
"notification-header-login-fail-known": "There {{PLURAL:$3|has been '''one failed attempt'''|have been '''$3 failed attempts'''}} to log in to your account since the last time you logged in. If this was you, then you can disregard this message. If it wasn't, please make sure your account has a strong password.",
|
||||
"notification-header-login-fail-new": "There {{PLURAL:$3|has been '''one failed attempt'''|have been '''$3 failed attempts'''}} to log in to your account since the last time you logged in. If this was you, then you can disregard this message. If it wasn't, please make sure your account has a strong password.",
|
||||
"notification-header-login-success": "Someone has successfully logged into your account from a computer which you have not edited from recently.",
|
||||
"notification-loginnotify-login-fail-new-emailbatch": "There {{PLURAL:$2|has been a failed attempt|have been $2 failed attempts}} to log in to your account '$1' on {{SITENAME}}. If this was you, then you can disregard this message. If it wasn't, please make sure your account has a strong password.",
|
||||
"notification-loginnotify-login-fail-known-emailbatch": "There {{PLURAL:$2|has been a failed attempt|have been $2 failed attempts}} to log in to your account, '$1' on {{SITENAME}}. If this was you, then you can disregard this message. If it wasn't, please make sure your account has a strong password.",
|
||||
"notification-loginnotify-login-success-emailbatch": "Someone has successfully logged into your account '$1' on {{SITENAME}} from a computer which you have not edited from recently."
|
||||
"notification-loginnotify-login-success-emailbatch": "Someone has successfully logged into your account '$1' on {{SITENAME}} from a computer which you have not edited from recently.",
|
||||
"notification-bundled-header-login-fail": "There have been '''$1 failed attempts''' to login to your account since the last time you logged in. If this was you, then you can disregard this message. If it wasn't, please make sure your account has a strong password.",
|
||||
"notification-unbundled-header-login-fail": "There have been multiple failed login attempts to your account. Please make sure your account has a strong password."
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"@metadata": {
|
||||
"authors": [
|
||||
"Brian Wolff"
|
||||
"Brian Wolff",
|
||||
"Niharika"
|
||||
]
|
||||
},
|
||||
"loginnotify-desc": "{{desc|name=LoginNotify|url=https://www.mediawiki.org/wiki/Extension:LoginNotify}}",
|
||||
|
@ -12,10 +13,10 @@
|
|||
"loginnotify-login-fail": "FIXME I have no idea where this message is used.\n{{notranslate}}",
|
||||
"notification-loginnotify-login-fail-email-subject": "Email subject line for email notice that there have been failed login attempts for the user's account. $1 is the user in question.",
|
||||
"notification-loginnotify-login-success-email-subject": "Email subject line for email notice that someone has logged in to the user's account from a computer that has not previously been used. $1 is the user in question.",
|
||||
"notification-header-login-fail-known": "Text of notification for failed login attempt from a known computer. This is shown in the user's echo notifications, and is emailed to the user.\n* $1 = Username for account, formatted for display\n* $2 = Username for account, unformatted for use in GENDER\n* $3 = Number of failed login attempts so far",
|
||||
"notification-header-login-fail-new": "Text of notification for failed login attempt from a computeri that is not recognized. This is shown in the user's echo notifications, and is emailed to the user.\n* $1 = Username for account, formatted for display\n* $2 = Username for account, unformatted for use in GENDER\n* $3 = Number of failed login attempts so far",
|
||||
"notification-header-login-success": "Text of notification for when someone successfully logs in as the current account from a computer that has not been previously used by that account. This is shown in the user's echo notifications, and is possibly emailed to the user.\n* $1 = Username for account, formatted for display\n* $2 = Username for account, unformatted for use in GENDER",
|
||||
"notification-loginnotify-login-fail-new-emailbatch": "Body of email notification that someone from a computer not previously used by the user has attempted and failed to log into the user's account. Subject of Message is {{msg-mw|notification-loginnotify-login-fail-email-subject}}. $1 is account name. $2 is the number of attempts",
|
||||
"notification-loginnotify-login-fail-known-emailbatch": "Body of email notification that someone from a computer which has been previously used by the user has attempted and failed to log into the user's account. Subject of Message is {{msg-mw|notification-loginnotify-login-fail-email-subject}}. $1 is account name. $2 is the number of attempts",
|
||||
"notification-loginnotify-login-success-emailbatch": "Body of email notification that someone from a computer not previously used by the user has succesfully logged into the user's account. Subject of Message is {{msg-mw|notification-loginnotify-login-success-email-subject}}. $1 is account name."
|
||||
"notification-loginnotify-login-success-emailbatch": "Body of email notification that someone from a computer not previously used by the user has succesfully logged into the user's account. Subject of Message is {{msg-mw|notification-loginnotify-login-success-email-subject}}. $1 is account name.",
|
||||
"notification-bundled-header-login-fail": "Message string shown for bundled notifications",
|
||||
"notification-unbundled-header-login-fail": "Message string shown for individual notifications when the bundle disperses"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue