I would suggest following laravel conventions, makes things so much easier. Otherwise see documentation on custom guards.
Laravel 10 Auth Login not working with custom Users table and column names
Info I have custom name an columns for my Users table and I'm using MSSQL for database. My table is called 'TUsers' and for columns I'm using PascalCase so I have:
'Email' instead of 'email' 'Password' instead of 'password' And all others like created_at, updated_at and remember_token Registering works fine but there the user is automatically logged in with Auth::login()
The problem Trying to login returns error "These credentials do not match our records." I have also tried to make a custom LoginController with my own function and I get the same issue using Auth::attempt
Tried using bcrypt() as well What I've tried I've added this to my User model
public $table = "TUsers"; protected $primaryKey = 'TUserID';
const EMAIL = 'Email'; const PASSWROD = 'Password'; const CREATED_AT = 'CreatedAt'; const UPDATED_AT = 'UpdatedAt';
public function getAuthPassword() { return $this->Password; }
protected $fillable = [ 'Name', 'Email', 'Password', 'EmailVerifiedAt' ];
protected $hidden = [ 'Password', 'RememberToken', ];
protected $casts = [ 'EmailVerifiedAt' => 'datetime', 'Password' => 'hashed', ]; I've also made the following adjustments to auth.php
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
'credentials' => [
'email' => 'Email',
'password' => 'Password'
]
],
], 'passwords' => [ 'users' => [ 'provider' => 'users', 'table' => 'PasswordResets', 'expire' => 60, 'throttle' => 60, ], ], I've also tried mkaing a custom TUserProvider
Please or to participate in this conversation.