Commit 82cb16b7 authored by luisfrl's avatar luisfrl
Browse files

feat: retirando case sensitive de email no login

parent 8f7b05be
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider class AuthServiceProvider extends ServiceProvider
{ {
...@@ -26,6 +25,8 @@ class AuthServiceProvider extends ServiceProvider ...@@ -26,6 +25,8 @@ class AuthServiceProvider extends ServiceProvider
{ {
$this->registerPolicies(); $this->registerPolicies();
// $this->app->auth->provider('eloquent.custom', function ($app, array $config) {
return new UserProvider($app['hash'], $config['model']);
});
} }
} }
<?php
namespace App\Providers;
use Illuminate\Support\Str;
use Illuminate\Auth\EloquentUserProvider;
use Illuminate\Contracts\Auth\UserProvider as UserProviderContract;
use Illuminate\Contracts\Support\Arrayable;
class UserProvider extends EloquentUserProvider implements UserProviderContract
{
public function retrieveByCredentials(array $credentials)
{
if (empty($credentials) ||
(count($credentials) === 1 &&
Str::contains($this->firstCredentialKey($credentials), 'password'))) {
return;
}
$query = $this->newModelQuery();
foreach ($credentials as $key => $value) {
if (Str::contains($key, 'password')) {
continue;
}
if (Str::contains($key, 'email')) {
$query->where($key, 'ilike', $value);
continue;
}
if (is_array($value) || $value instanceof Arrayable) {
$query->whereIn($key, $value);
} else {
$query->where($key, $value);
}
}
return $query->first();
}
}
\ No newline at end of file
...@@ -6,7 +6,6 @@ use App\Notifications\recuperacaoSenha; ...@@ -6,7 +6,6 @@ use App\Notifications\recuperacaoSenha;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use App\Notifications\VerifyNotification; use App\Notifications\VerifyNotification;
use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Contracts\Auth\CanResetPassword;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements MustVerifyEmail class User extends Authenticatable implements MustVerifyEmail
...@@ -44,6 +43,16 @@ class User extends Authenticatable implements MustVerifyEmail ...@@ -44,6 +43,16 @@ class User extends Authenticatable implements MustVerifyEmail
'email_verified_at' => 'datetime', 'email_verified_at' => 'datetime',
]; ];
public function getEmailAttribute($value)
{
return strtolower($value);
}
public function setEmailAttribute($value)
{
$this->attributes['email'] = strtolower($value);
}
public function trabalho(){ public function trabalho(){
return $this->hasMany('App\Trabalho', 'autorId'); return $this->hasMany('App\Trabalho', 'autorId');
} }
......
...@@ -67,7 +67,7 @@ return [ ...@@ -67,7 +67,7 @@ return [
'providers' => [ 'providers' => [
'users' => [ 'users' => [
'driver' => 'eloquent', 'driver' => 'eloquent.custom',
'model' => App\User::class, 'model' => App\User::class,
], ],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment