First of all, I have seen this topics (and many others):
Laravel Auth::attempt() always false?
Laravel 5 Auth:attempt() always returns false
But I have been unable to login in my app. I'm using Laravel 5.6 and my table is called oc_users
.
DB::table('oc_users')->insert(
[
'email' => '[email protected]',
'pwd' => bcrypt('123456'),
'active' => true
]);
I went to the file Laravel > App > User.php and changed to:
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
protected $table = 'oc_users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['email', 'pwd'];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = ['pwd', 'remember_token'];
}
And the code to perform the login:
public function form_login(Request $request)
{
if($request->filled('email') == FALSE || $request->filled('pwd') == FALSE)
return Redirect::back()->withErrors('Fill the credentials');
if (Auth::attempt(['email' => $request->email, 'pwd' => $request->pwd]))
return redirect()->intended('app');
return Redirect::back()->withErrors('Email or password wrong');
}
I also went to the file App > Config > Auth.php trying to figure out if there's a table I need to change but it doesn't seem to exists in Laravel 5.6
oc_users
table? – Julian van den Berkmortel