Expand warning with better text

This commit is contained in:
James Cole
2020-08-29 07:18:41 +02:00
parent 2a02e8a790
commit e159de9a6a
4 changed files with 23 additions and 7 deletions

View File

@@ -35,7 +35,8 @@ class NewIPAddressWarningMail extends Mailable
use Queueable, SerializesModels; use Queueable, SerializesModels;
public string $ipAddress; public string $ipAddress;
public string $time;
public string $host;
/** /**
* OAuthTokenCreatedMail constructor. * OAuthTokenCreatedMail constructor.
* *
@@ -53,6 +54,14 @@ class NewIPAddressWarningMail extends Mailable
*/ */
public function build(): self 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') return $this->view('emails.new-ip-html')->text('emails.new-ip-text')
->subject((string) trans('email.login_from_new_ip')); ->subject((string) trans('email.login_from_new_ip'));
} }

View File

@@ -34,9 +34,12 @@ return [
'admin_test_body' => 'This is a test message from your Firefly III instance. It was sent to :email.', 'admin_test_body' => 'This is a test message from your Firefly III instance. It was sent to :email.',
// new IP // new IP
'login_from_new_ip' => 'You logged in from an unknown IP address.', 'login_from_new_ip' => 'New login on Firefly III',
'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_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 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!', '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
'access_token_created_subject' => 'A new access token was created', 'access_token_created_subject' => 'A new access token was created',

View File

@@ -3,8 +3,10 @@
{{ trans('email.new_ip_body') }} {{ trans('email.new_ip_body') }}
</p> </p>
<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;font-weight: bold;"> <p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">
{{ ipAddress }} {{ trans('email.ip_address') }}: <strong>{{ ipAddress }}</strong><br />
{% if ''!= host %}{{ trans('email.host_name') }}: {{ host }}<br />{% endif %}
{{ trans('email.date_time') }}: {{ time }}<br />
</p> </p>
<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;"> <p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">

View File

@@ -1,7 +1,9 @@
{% include 'emails.header-text' %} {% include 'emails.header-text' %}
{{ trans('email.new_ip_body') }} {{ 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') }} {{ trans('email.new_ip_warning') }}