Error when blocked user logs in

This commit is contained in:
James Cole 2016-03-18 11:10:51 +01:00
parent b5c5f67fcc
commit 9c58b77f01
3 changed files with 57 additions and 0 deletions

View File

@ -82,6 +82,28 @@ class AuthController extends Controller
$code = 'general_blocked';
}
$message = strval(trans('firefly.' . $code . '_error', ['email' => $credentials['email']]));
// send a message home about the blocked attempt to login.
// perhaps in a later stage, simply log these messages.
// send email.
try {
$email = env('SITE_OWNER', false);
$fields = [
'user_id' => $foundUser->id,
'email' => $credentials['email'],
'code' => $code,
'message' => $message,
'ip' => $request->ip(),
];
Mail::send(
['emails.blocked-login-html', 'emails.blocked-login'], $fields, function (Message $message) use ($email) {
$message->to($email, $email)->subject('Blocked a login attempt.');
}
);
} catch (\Swift_TransportException $e) {
Log::error($e->getMessage());
}
}
if ($throttles) {

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body itemscope itemtype="http://schema.org/SoftwareApplication">
<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">
Hey there,
</p>
<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">
Firefly III has just blocked a login from user #{{ user_id }} ({{ email }}).
</p>
<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">
The blocked code was "{{ code }}" and the subsequent message was:
</p>
<p style="font-family: monospace;font-size:13px;">
"{{ message }}"
</p>
<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:11px;color:#aaa;">
The login attempt came from IP {{ ip }}.
</p>
</body>
</html>

View File

@ -0,0 +1,8 @@
Hey there,
Firefly III has just blocked a login from user #{{ user_id }} ({{ email }}).
The blocked code was "{{ code }}" and the subsequent message was:
"{{ message }}"
The login attempt came from IP {{ ip }}