I want to manually authenticate a user in Laravel 5. My application uses 2 databases, which are located on the same server. In my application i already switch connections in the models or query builder, which works perfect.
But now i want to use laravels Auth::attempt
method to login a user. But the credentials for this user are stored in the second database.
In the user model i have: protected $connection = 'first_database';
This is the database it normally should use. But for this 'special' login, i want the user model to use the second_database
.
Is this possible?
What i tried:
\Config::set('database.default', 'second_database');
// Login this user while using the second_database
if(\Auth::attempt(['email'=>\Request::get('email'), 'password'=>\Request::get('password')]))
{
dd('Success');
}
But unfortunately, this doesn't work. I`m using Laravel 5.1