Rename the column tg_user_pass password.
It will be best to do
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I try to authenticate using a custom table from existing database. Theri name is TG_users and the fields I use for the authentication are tg_user_name and tg_user_pass.
But qhen I try to login using Auth::attempt( $credentials ) ever launch the follow error.
Undefined index: password
Some idea?
@danjavia Modify your AuthController to this:
<?php
namespace App\Http\Controllers\Auth;
use Area\Models\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'tg_user_name' => 'required|max:255|unique:users',
'tg_user_pass' => 'required|confirmed|min:6',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'tg_user_name' => $data['tg_user_name'],
'tg_user_pass' => bcrypt($data['tg_user_pass']),
]);
}
protected function getCredentials(Request $request)
{
return $request->only($this->loginUsername(), 'tg_user_pass');
}
public function loginUsername()
{
return property_exists($this, 'tg_user_name') ? $this->tg_user_name : 'tg_user_name';
}
}
And make sure your login form is posting tg_user_name as username and tg_user_pass as password.
Hope this helps to point you on the right way
s.
Please or to participate in this conversation.