Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vostinariu-vlad's avatar

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

0 likes
5 replies
jlrdw's avatar

I would suggest following laravel conventions, makes things so much easier. Otherwise see documentation on custom guards.

1 like
vostinariu-vlad's avatar

@jlrdw I can't in this case, I've been using laravel for years and didn't have this problem, also made the same thing for another project years ago in versions 5, 8, but that time it was easier to simply override the traits used in LoginController and Register but I don't know why they changed how things work. I looked over a lot of core files and it seems there are some places where 'email' and 'password' are hardcoded which seems stupid considering how complex the Auth system is.

Snapey's avatar

provider is the table name

'guards' => [
'web' => [
    'driver' => 'session',
    'provider' => 'TUsers',
    'credentials' => [
        'email' => 'Email',
        'password' => 'Password'
    ]
],

as has been suggested, STICK TO CONVENTIONS if you want an easy project

What field names do you get from your form?

what starter kit?

1 like
vostinariu-vlad's avatar

UPDATE:

I created an empty laravel 10 empty app, using MySQL this time, by simply adjusting the $fillable + adding getAuthPassword() { return $this->Password; } and it's working here - in the initial project still not working.

Please or to participate in this conversation.