lock-laravel icon indicating copy to clipboard operation
lock-laravel copied to clipboard

Target [BeatSwitch\Lock\Drivers\Driver] is not instantiable.

Open lbausch opened this issue 9 years ago • 6 comments

First: I have seen Issue #3 but I'm using Laravel 5 and the latest version of laravel-lock, 0.2.1.

When trying dependency injection on the Controller (like suggested in the documentation)

public function __construct(\BeatSwitch\Lock\Manager $manager) {
    $this->lockManager = $manager;
}

this happens:

BindingResolutionException in Container.php line 785:
Target [BeatSwitch\Lock\Drivers\Driver] is not instantiable.

Any hints or suggestions?

lbausch avatar Apr 10 '15 18:04 lbausch

@driesvints I am also having this issue with a fresh L5 and Lock installation...

rtablada avatar Apr 14 '15 13:04 rtablada

I'm just gonna be honest with you guys. I don't have the time atm to look into this and probably won't have for the upcoming weeks. If anyone can take the time to figure this out, that'd be great :confused:

driesvints avatar Apr 17 '15 22:04 driesvints

@driesvints I'm not sure if this is the issue that @lbausch is having but I found that my issue was that I was resetting the Auth::user in my OAuth middleware.

The way that I got around this was to attach the Lock instance to the Auth user in a middleware after OAuth had set my proper user.

IMO since the Auth::user could be seen as part of the request it would be a good place to set the manager caller and such.

rtablada avatar Apr 30 '15 18:04 rtablada

It's ugly, but this is our middleware right now:

public function handle($request, Closure $next)
{
    $this->filter();

    $userId = $this->authorizer->getChecker()->getAccessToken()->getSession()->getOwnerId();


    try {
        Auth::onceUsingId($userId);
        $user = Auth::user();
        $manager = app('lock.manager');
        $lock = $manager->caller($user);

        Auth::user()->setLock($lock);
    } catch (Exception $e) {
        return Response::json(['error' => 'Unauthorized access'], 401);
    }

    return $next($request);
}

rtablada avatar Apr 30 '15 18:04 rtablada

Im taking a look at this issue, I am having the same problem.

tshafer avatar May 15 '15 15:05 tshafer

Can anyone test if this problem still happens in the latest release?

driesvints avatar Dec 18 '16 12:12 driesvints