I want to modify the login compartment of laravel, I want to do everything the same without encrypting the password.
This is the model:
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array*/
protected $fillable = [
'id','nombre', 'apellido1', 'apellido2',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
protected $table = 'usuario';
}
I modify LoginController overwritten the login function:
public function login(Request $request)
{
$this->validateLogin($request);
$email = $request->get('email');
$pass = $request->get('password');
$matchWhere = ['email' => $email, 'password' => $pass];
$user = User::where($matchWhere)->first();
if ($user ) {
Auth::guard('usuarios')->login($user);
return redirect()->intended('/home');
} else {
return $this->sendFailedLoginResponse($request);
}
}
And I create the specific guard in auth.php:
guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'usuarios' => [
'driver' => 'session',
'provider' => 'usuarios',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'usuarios' => [
'driver' => 'database',
'table' => 'usuario',
],
],
Finally I modify the app.blade.php using my own guard:
@if (Auth::guard('usuarios')->guest())
<li><a href="">Login</a></li>
<li><a href="">Register</a></li>
@else
-- logout
@endif
Why doesn't work? I modified the provider to eloquent and change the model. I try to use the default provider
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2HB8JYl
via IFTTT
Aucun commentaire:
Enregistrer un commentaire