I recently got into Laravel, and I wanted to create a User-System for my webapp.
I used php artisan make:auth to create the standart Authentication views/controllers of Laravel. Now I wanted to change the column names of the user table. I wanted to rename name to userName, email to userEmail, password to userPassword.
Registration works perfectly fine, Login has the issues though.
After doing exactly as described in http://www.lasselaursen.com/post/changing-standard-fieldcolumn-names-in-laravel-5s-default-users-table with a few small adjustments, for example instead of overriding postLogin in AuthController, i overrode login in LoginController.
When I try to login now I always get the debug window saying: Undefined index: password in ..\vendor\laravel\framework\src\Illuminate\Auth\GenericUser.php
I overrode the function getAuthPassword() in class User.php as follows
public function getAuthPassword()
{
return $this->userPassword;
}
My login function on LoginController looks as follows:
public function login(Request $request)
{
$this->validate($request, [
'userEmail' => 'required|email', 'password' => 'required',
]);
$credentials = $request->only('userEmail', 'password');
if (Auth::attempt($credentials, $request->has('remember')))
{
return redirect()->intended($this->redirectTo);
}
return redirect($this->loginPath())
->withInput($request->only('userEmail', 'remember'))
->withErrors([
'userEmail' => $this->getFailedLoginMessage(),
]);
}
I changed the name field in login.blade.php of the mail to userEmail and left the field for password as password.
I feel like I'm missing something really obvious here, but I just cant find it...
If you need more code snippets just hit me up.
<input type="password" name="password" placeholder="password"/>
name attribute in this case. – user3647971public function getAuthPassword() { return $this->attributes['password']; }
While my overridden function would look as shown in the original post above. – Paul Rangger