1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Http/ValidationRules/UniqueUserRule.php
David Bomba f745c3f0a6
Working on Social Authentication (#2458)
* 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
2018-10-18 16:04:36 +11:00

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);
}
}