mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
f745c3f0a6
* Laravel Socialite + Refactor for searching for Users across multiple databases * Refactor for Unique User Rules, add Middleware for setting active DB connection per request, more tests
28 lines
538 B
PHP
28 lines
538 B
PHP
<?php
|
|
|
|
namespace App\Http\ValidationRules;
|
|
|
|
use App\Libraries\MultiDB;
|
|
use App\Models\User;
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
class UniqueUserRule implements Rule
|
|
{
|
|
|
|
public function passes($attribute, $value)
|
|
{
|
|
return ! $this->checkIfEmailExists($value); //if it exists, return false!
|
|
}
|
|
|
|
public function message()
|
|
{
|
|
return trans('texts.email_already_register');
|
|
}
|
|
|
|
private function checkIfEmailExists($email) : bool
|
|
{
|
|
return MultiDB::checkUserEmailExists($email);
|
|
}
|
|
|
|
}
|