diff --git a/LoginNotify.hooks.php b/LoginNotify.hooks.php index 3fa6426..6b78afc 100644 --- a/LoginNotify.hooks.php +++ b/LoginNotify.hooks.php @@ -89,7 +89,6 @@ class LoginNotifyHooks { public static function onEchoGetBundleRules( $event, &$bundleString ) { switch ( $event->getType() ) { - case 'login-fail-known': case 'login-fail-new': $bundleString = 'login-fail'; break; diff --git a/LoginNotifyPresentationModel.php b/LoginNotifyPresentationModel.php index 3997c63..318dab0 100644 --- a/LoginNotifyPresentationModel.php +++ b/LoginNotifyPresentationModel.php @@ -27,17 +27,34 @@ class LoginNotifyPresentationModel extends EchoEventPresentationModel { public function getHeaderMessage() { // 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; + $msg = ''; + switch ( $this->event->getType() ) { + case 'login-fail-known': + if ( $this->event->getExtraParam( 'count', 0 ) > 0 ) { + $msg = $this->msg( 'notification-known-header-login-fail' ); + $msg->params( $this->event->getExtraParam( 'count', 0 ) ); + return $msg; + } else { + $msg = $this->msg( 'notification-header-login-success' ); + $msg->params( $this->event->getExtraParam( 'count', 0 ) ); + return $msg; + } + break; + case 'login-fail-new': + if ( $this->isBundled() && ( $this->event->getExtraParam( 'count', 0 ) > 0 ) ) { + $msg = $this->msg( 'notification-new-bundled-header-login-fail' ); + $msg->params( $this->event->getExtraParam( 'count', 0 ) ); + return $msg; + } elseif ( $this->event->getExtraParam( 'count', 0 ) > 0 ) { + $msg = $this->msg( 'notification-new-unbundled-header-login-fail' ); + return $msg; + } else { + $msg = $this->msg( 'notification-header-login-success' ); + return $msg; + } + break; } + return $msg; } /** diff --git a/i18n/en.json b/i18n/en.json index bc9d9f6..df53dff 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -15,9 +15,10 @@ "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-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-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 it wasn't you, 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 it wasn't you, 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-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." + "notification-new-bundled-header-login-fail": "There {{PLURAL:$1|has been '''a failed attempt'''|have been '''$1 failed attempts'''}} to log in to your account from a new device since the last time you logged in. If it wasn't you, please make sure your account has a strong password.", + "notification-known-header-login-fail": "There have been {{PLURAL:$1|has been '''a failed attempt'''|have been '''$1 failed attempts'''}} to log in to your account since the last time you logged in. If it wasn't you, please make sure your account has a strong password.", + "notification-new-unbundled-header-login-fail": "There have been multiple failed attempts to log in to your account from a new device. Please make sure your account has a strong password." } diff --git a/i18n/qqq.json b/i18n/qqq.json index a38b862..9a749c5 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -17,6 +17,7 @@ "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-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" + "notification-new-bundled-header-login-fail": "Message string shown for bundled notifications for login attempts from a new device", + "notification-known-header-login-fail": "Message string shown for known IP notifications", + "notification-new-unbundled-header-login-fail": "Message string shown for individual notifications for login attempts from a new device, when the bundle disperses" }