From e159de9a6adc1a049cad09f0a130958198706393 Mon Sep 17 00:00:00 2001
From: James Cole
Date: Sat, 29 Aug 2020 07:18:41 +0200
Subject: [PATCH] Expand warning with better text
---
app/Mail/NewIPAddressWarningMail.php | 11 ++++++++++-
resources/lang/en_US/email.php | 9 ++++++---
resources/views/v1/emails/new-ip-html.twig | 6 ++++--
resources/views/v1/emails/new-ip-text.twig | 4 +++-
4 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/app/Mail/NewIPAddressWarningMail.php b/app/Mail/NewIPAddressWarningMail.php
index b66790c851..3bf5e5ef8d 100644
--- a/app/Mail/NewIPAddressWarningMail.php
+++ b/app/Mail/NewIPAddressWarningMail.php
@@ -35,7 +35,8 @@ class NewIPAddressWarningMail extends Mailable
use Queueable, SerializesModels;
public string $ipAddress;
-
+ public string $time;
+ public string $host;
/**
* OAuthTokenCreatedMail constructor.
*
@@ -53,6 +54,14 @@ class NewIPAddressWarningMail extends Mailable
*/
public function build(): self
{
+ // time
+ $this->time = now()->formatLocalized((string)trans('config.date_time'));
+ $this->host = '';
+ $host = gethostbyaddr($this->ipAddress);
+ if($host !== $this->ipAddress) {
+ $this->host = $host;
+ }
+
return $this->view('emails.new-ip-html')->text('emails.new-ip-text')
->subject((string) trans('email.login_from_new_ip'));
}
diff --git a/resources/lang/en_US/email.php b/resources/lang/en_US/email.php
index 773dc1bc4f..a9a587838e 100644
--- a/resources/lang/en_US/email.php
+++ b/resources/lang/en_US/email.php
@@ -34,9 +34,12 @@ return [
'admin_test_body' => 'This is a test message from your Firefly III instance. It was sent to :email.',
// new IP
- 'login_from_new_ip' => 'You logged in from an unknown IP address.',
- 'new_ip_body' => 'You logged in from a new, unknown IP address. If you never logged in from the IP address below, or it has been more than six months, Firefly III will warn you.',
- 'new_ip_warning' => 'If you didn\'t login, of if you have no idea what this is about, verify your password security, change it, and log out all other sessions. To do this, go to your profile page. Of course you have 2FA enabled already, right? Stay safe!',
+ 'login_from_new_ip' => 'New login on Firefly III',
+ 'new_ip_body' => 'Firefly III detected a new login on your account from an unknown IP address. If you never logged in from the IP address below, or it has been more than six months ago, Firefly III will warn you.',
+ 'new_ip_warning' => 'If you recognize this IP address or the login, you can ignore this message. If you didn\'t login, of if you have no idea what this is about, verify your password security, change it, and log out all other sessions. To do this, go to your profile page. Of course you have 2FA enabled already, right? Stay safe!',
+ 'ip_address' => 'IP address',
+ 'host_name' => 'Host',
+ 'date_time' => 'Date + time',
// access token created
'access_token_created_subject' => 'A new access token was created',
diff --git a/resources/views/v1/emails/new-ip-html.twig b/resources/views/v1/emails/new-ip-html.twig
index 2d0b172226..7c0c56e6b0 100644
--- a/resources/views/v1/emails/new-ip-html.twig
+++ b/resources/views/v1/emails/new-ip-html.twig
@@ -3,8 +3,10 @@
{{ trans('email.new_ip_body') }}
-
- {{ ipAddress }}
+
+ {{ trans('email.ip_address') }}: {{ ipAddress }}
+ {% if ''!= host %}{{ trans('email.host_name') }}: {{ host }}
{% endif %}
+ {{ trans('email.date_time') }}: {{ time }}
diff --git a/resources/views/v1/emails/new-ip-text.twig b/resources/views/v1/emails/new-ip-text.twig
index 9eca2aa6d2..b5b55dfe4a 100644
--- a/resources/views/v1/emails/new-ip-text.twig
+++ b/resources/views/v1/emails/new-ip-text.twig
@@ -1,7 +1,9 @@
{% include 'emails.header-text' %}
{{ trans('email.new_ip_body') }}
-{{ ipAddress }}
+{{ trans('email.ip_address') }}: {{ ipAddress }}
+{% if ''!= host %}{{ trans('email.host_name') }}: {{ host }}{% endif %}
+{{ trans('email.date_time') }}: {{ time }}
{{ trans('email.new_ip_warning') }}