Skip to content

Firefly III: a personal finances manager

Can block certain domains from registering, such as ten-minute-mail services. Two example domains provided in configuration.

James Cole56c08d8302f7
diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php
index 7caeb6b87d..cd84b74d15 100644
--- a/app/Http/Controllers/Auth/AuthController.php
+++ b/app/Http/Controllers/Auth/AuthController.php
@@ -14,6 +14,7 @@ use Session;
use Twig;
use Validator;
use Log;
+use Config;
/**
* Class AuthController
@@ -88,8 +89,8 @@ class AuthController extends Controller
$foundUser = User::where('email', $credentials['email'])->where('blocked', 1)->first();
if (!is_null($foundUser)) {
// if it exists, show message:
- $code = $foundUser->blocked_code;
- if(strlen($code) == 0) {
+ $code = $foundUser->blocked_code;
+ if (strlen($code) == 0) {
$code = 'general_blocked';
}
$message = trans('firefly.' . $code . '_error', ['email' => $credentials['email']]);
@@ -160,9 +161,20 @@ class AuthController extends Controller
}
// @codeCoverageIgnoreEnd
+
$data = $request->all();
$data['password'] = bcrypt($data['password']);
+ // is user email domain blocked?
+ $parts = explode('@', $data['email']);
+ if (isset($parts[1]) && in_array($parts[1], Config::get('mail.blocked_domains'))) {
+
+ $validator->getMessageBag()->add('email', trans('validation.invalid_domain'));
+ $this->throwValidationException(
+ $request, $validator
+ );
+ }
+
Auth::login($this->create($data));
// get the email address
diff --git a/config/mail.php b/config/mail.php
index 31c5eaa8a2..be1dda92b8 100644
--- a/config/mail.php
+++ b/config/mail.php
@@ -15,7 +15,8 @@ return [
|
*/
- 'driver' => env('EMAIL_DRIVER', 'smtp'),
+ 'blocked_domains' => ['trbvm.com', 'example.com'],
+ 'driver' => env('EMAIL_DRIVER', 'smtp'),
/*
|--------------------------------------------------------------------------
@@ -28,7 +29,7 @@ return [
|
*/
- 'host' => env('EMAIL_SMTP', 'smtp.mailgun.org'),
+ 'host' => env('EMAIL_SMTP', 'smtp.mailgun.org'),
/*
|--------------------------------------------------------------------------
@@ -41,7 +42,7 @@ return [
|
*/
- 'port' => 587,
+ 'port' => 587,
/*
|--------------------------------------------------------------------------
@@ -54,7 +55,7 @@ return [
|
*/
- 'from' => ['address' => env('EMAIL_USERNAME', null), 'name' => 'Firefly III Mailer'],
+ 'from' => ['address' => env('EMAIL_USERNAME', null), 'name' => 'Firefly III Mailer'],
/*
|--------------------------------------------------------------------------
@@ -80,7 +81,7 @@ return [
|
*/
- 'username' => env('EMAIL_USERNAME', null),
+ 'username' => env('EMAIL_USERNAME', null),
/*
|--------------------------------------------------------------------------
@@ -93,7 +94,7 @@ return [
|
*/
- 'password' => env('EMAIL_PASSWORD', null),
+ 'password' => env('EMAIL_PASSWORD', null),
/*
|--------------------------------------------------------------------------
@@ -106,7 +107,7 @@ return [
|
*/
- 'sendmail' => '/usr/sbin/sendmail -bs',
+ 'sendmail' => '/usr/sbin/sendmail -bs',
/*
|--------------------------------------------------------------------------
@@ -119,6 +120,6 @@ return [
|
*/
- 'pretend' => env('EMAIL_PRETEND', false),
+ 'pretend' => env('EMAIL_PRETEND', false),
];
diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php
index 9aede79f7d..af5cb84b1b 100644
--- a/resources/lang/en/validation.php
+++ b/resources/lang/en/validation.php
@@ -13,6 +13,7 @@ return [
|
*/
+ 'invalid_domain' => 'Cannot register from this domain.',
'file_already_attached' => 'Uploaded file ":name" is already attached to this object.',
'file_attached' => 'Succesfully uploaded file ":name".',
'file_invalid_mime' => 'File ":name" is of type ":mime" which is not accepted as a new upload.',
@@ -92,7 +93,7 @@ return [
|
*/
- 'custom' => [
+ 'custom' => [
'attribute-name' => [
'rule-name' => 'custom-message',
],
@@ -109,6 +110,6 @@ return [
|
*/
- 'attributes' => [],
+ 'attributes' => [],
];
diff --git a/resources/lang/nl/validation.php b/resources/lang/nl/validation.php
index 8c8a7cfa3c..28c536cba5 100644
--- a/resources/lang/nl/validation.php
+++ b/resources/lang/nl/validation.php
@@ -13,6 +13,7 @@ return [
|
*/
+ 'invalid_domain' => 'Kan niet registereren vanaf dit domein.',
'file_already_attached' => 'Het geuploade bestand ":name" is al gelinkt aan deze transactie.',
'file_attached' => 'Bestand met naam ":name" is met succes geuploaded.',
'file_invalid_mime' => 'Bestand ":name" is van het type ":mime", en die kan je niet uploaden.',