mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-29 02:11:12 -06:00
Cleanup routine that checks for blocked domains.
This commit is contained in:
parent
d7e838701a
commit
7921d128e4
@ -1,6 +1,7 @@
|
||||
<?php namespace FireflyIII\Http\Controllers\Auth;
|
||||
|
||||
use Auth;
|
||||
use Config;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Role;
|
||||
use FireflyIII\User;
|
||||
@ -8,13 +9,12 @@ use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
use Illuminate\Foundation\Auth\ThrottlesLogins;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Mail\Message;
|
||||
use Log;
|
||||
use Mail;
|
||||
use Request as Rq;
|
||||
use Session;
|
||||
use Twig;
|
||||
use Validator;
|
||||
use Log;
|
||||
use Config;
|
||||
|
||||
/**
|
||||
* Class AuthController
|
||||
@ -165,9 +165,7 @@ class AuthController extends Controller
|
||||
$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'))) {
|
||||
|
||||
if ($this->isBlockedDomain($data['email'])) {
|
||||
$validator->getMessageBag()->add('email', trans('validation.invalid_domain'));
|
||||
$this->throwValidationException(
|
||||
$request, $validator
|
||||
@ -178,8 +176,8 @@ class AuthController extends Controller
|
||||
|
||||
// get the email address
|
||||
if (Auth::user() instanceof User) {
|
||||
$email = Auth::user()->email;
|
||||
$address = route('index');
|
||||
$email = Auth::user()->email;
|
||||
$address = route('index');
|
||||
$ipAddress = $request->ip();
|
||||
// send email.
|
||||
try {
|
||||
@ -188,7 +186,7 @@ class AuthController extends Controller
|
||||
$message->to($email, $email)->subject('Welcome to Firefly III! ');
|
||||
}
|
||||
);
|
||||
} catch(\Swift_TransportException $e) {
|
||||
} catch (\Swift_TransportException $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
|
||||
@ -213,6 +211,32 @@ class AuthController extends Controller
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getBlockedDomains() {
|
||||
$set = Config::get('mail.blocked_domains');
|
||||
$domains = [];
|
||||
foreach($set as $entry) {
|
||||
$domain = trim($entry);
|
||||
if(strlen($domain) > 0) {
|
||||
$domains[] = $domain;
|
||||
}
|
||||
}
|
||||
return $domains;
|
||||
}
|
||||
|
||||
protected function isBlockedDomain($email)
|
||||
{
|
||||
$parts = explode('@', $email);
|
||||
$blocked = $this->getBlockedDomains();
|
||||
|
||||
if (isset($parts[1]) && in_array($parts[1], $blocked)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
|
@ -15,7 +15,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'blocked_domains' => ['trbvm.com', 'example.com','mailinator.com'],
|
||||
'blocked_domains' => explode(',', env('BLOCKED_DOMAINS')),
|
||||
'driver' => env('EMAIL_DRIVER', 'smtp'),
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user