did you hash the password in tinker?
using different model for user authentication
I want to use a different model (Member) for user authentication throughout my entire laravel application.
So the first logic step would be to make the member model authenticable:
// Member.php
use Illuminate\Foundation\Auth\User as Authenticatable;
class Member extends Authenticatable
{
protected $table = 'members';
protected $fillable = [
'first_name', 'last_name', 'email', 'password'
];
protected $hidden = [
'password', 'remember_token',
];
}
then in auth.php:
'defaults' => [
'guard' => 'member',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'member' => [
'driver' => 'session',
'provider' => 'members',
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'members' => [
'driver' => 'eloquent',
'model' => App\Models\Member::class,
],
if i then create a user in tinker, the user gets created
but attempting to fill in the form at/login, i get an error: these credentials do not match our records
i came across this:
https://laravel.com/docs/5.6/authentication#adding-custom-guards
if i understand it correctly, i still use the session guard, so i don't need a custom guard?
Can someone tell me what i am missing? Why i can't login? If any further information is required, please let me know, i will gladly add it.
Okay, the problem was a protected $password attribute of Member class. For the rest my approach was correct.
Please or to participate in this conversation.