Have you renamed the applicable fields in the various places such as the forms?
I suggest you use the laravel conventions. You could rename your table. Backup first.
Suggestion only
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am currently working with Laravel 11 and facing an issue with the default authentication system when using custom table and column names. Laravel's default authentication assumes the presence of a users table with columns email and password. However, I have created my own table (ipUsers) with custom column names (ipUsers_email and ipUsers_password), which is causing issues when trying to authenticate users.
Problem I have correctly configured my login controller and authentication settings, but I'm getting an error:
Undefined array key "password"
The error occurs in EloquentUserProvider.php on line 151 when Laravel tries to validate the user credentials using the password field. Specifically, Laravel expects the credentials array to include a password key, but it's unable to find it because of the custom column names.
Current Login Controller Here is my login controller code:
public function login(Request $request)
{
$credentials = [
'ipUsers_email' => $request->input('email'),
'ipUsers_password' => $request->input('password'),
];
$request->validate([
'email' => 'required|email',
'password' => 'required',
'profile' => 'required|numeric',
]);
if (Auth::attempt($credentials)) {
return response()->json(['message' => 'Valid login details'], 200);
} else {
return response()->json(['error' => 'Wrong login details'], 401);
}
}
Issue in auth.php Configuration
My config/auth.php is configured as follows:
'defaults' => [
'guard' => env('AUTH_GUARD', 'web'),
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
'passwords' => 'ipUsers',
'table' => 'ipUsers',
'identifier' => 'ipUsers_email',
],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
'expire' => 60,
'throttle' => 60,
],
],
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
User Model My custom User model is set up as follows:
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable{
use HasFactory, Notifiable;
protected $table = "ipUsers_users"; // Custom table name
protected $primaryKey = "ipUsers_id"; // Custom primary key
const CREATED_AT = 'ipUsers_addDate';
const UPDATED_AT = 'ipUsers_editDate';
protected $fillable = [
'ipUsers_firstName',
'ipUsers_middleName',
'ipUsers_lastName',
'ipUsers_email',
'ipUsers_password',
'ipUsers_verifyStatus',
'ipUsers_verifyDate',
'ipUsers_verifyKey',
'ipUsers_sofDelete',
'ipUsers_addDate',
];
protected $hidden = [
'ipUsers_password',
'ipUsers_verifyKey',
];
public function getAuthIdentifierName()
{
return 'ipUsers_email'; // Custom email column
}
public function getAuthPassword()
{
return $this->ipUsers_password; // Custom password column
}
}
Error Explanation The error is caused by Laravel trying to access the password field in the $credentials array during the authentication attempt, but it can't find it because the credentials array uses the custom field name ipUsers_password instead of password.
This happens because the Auth::attempt() function by default expects the array to contain a password key, as that's what Laravel's authentication system looks for when checking the credentials.
Please or to participate in this conversation.