Consider the following:
namespace App\ART\Domain\Services;
use App\ART\Domain\Entities\User;
use Illuminate\Support\Facades\Auth;
/**
* Handle Sessions.
*/
class SessionService {
/**
* Create a new session based on user id.
*
* @param User $user
*/
public function createSession(User $user) {
Auth::loginUsingId($user->id);
}
/**
* Destroy a session if it exists.
*/
public function destroySession() {
if (Auth::check()) {
Auth::logout();
}
}
}
Pretty basic, nothing fancy going on here. Create a new session based on the specific user id.
How ever now I get:
ErrorException in Guard.php line 430:
Argument 1 passed to Illuminate\Auth\Guard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\ART\Domain\Models\User given, called in /var/www/AppResponseTracker/vendor/laravel/framework/src/Illuminate/Auth/Guard.php on line 489 and defined
A bit of the stack trace:
in Guard.php line 430
at HandleExceptions->handleError('4096', 'Argument 1 passed to Illuminate\Auth\Guard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\ART\Domain\Models\User given, called in /var/www/AppResponseTracker/vendor/laravel/framework/src/Illuminate/Auth/Guard.php on line 489 and defined', '/var/www/AppResponseTracker/vendor/laravel/framework/src/Illuminate/Auth/Guard.php', '430', array()) in Guard.php line 430
at Guard->login(object(User), false) in Guard.php line 489
at Guard->loginUsingId('1')
at call_user_func_array(array(object(Guard), 'loginUsingId'), array('1')) in Manager.php line 137
at Manager->__call('loginUsingId', array('1')) in Facade.php line 210
at AuthManager->loginUsingId('1') in Facade.php line 210
at Facade::__callStatic('loginUsingId', array('1')) in SessionService.php line 19
at Auth::loginUsingId('1') in SessionService.php line 19
The last line: at Auth::loginUsingId('1') in SessionService.php line 19
Did they change something that prevents me from passing in an ID?
Update!!
I have code else where that states if the user is logged in Auth::check()
then allow access to a route and if not don't. After this error is thrown access is granted ...
This doesn't seem right ...
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire