Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Walter Felipe
submeta
Commits
82cb16b7
Commit
82cb16b7
authored
May 23, 2023
by
luisfrl
Browse files
feat: retirando case sensitive de email no login
parent
8f7b05be
Changes
4
Show whitespace changes
Inline
Side-by-side
app/Providers/AuthServiceProvider.php
View file @
82cb16b7
...
@@ -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'
]);
});
}
}
}
}
app/Providers/UserProvider.php
0 → 100644
View file @
82cb16b7
<?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
app/User.php
View file @
82cb16b7
...
@@ -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'
);
}
}
...
...
config/auth.php
View file @
82cb16b7
...
@@ -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
,
],
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment