Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arg 1 passed to SessionGuard::quietLogin() must implement interface Authenticatable, instance of Collection given #17

Closed
jackcruden opened this issue Oct 19, 2018 · 8 comments

Comments

@jackcruden
Copy link

jackcruden commented Oct 19, 2018

Symfony\Component\Debug\Exception\FatalThrowableError: Argument 1 passed to Lab404\Impersonate\Guard\SessionGuard::quietLogin() must implement interface Illuminate\Contracts\Auth\Authenticatable, instance of Illuminate\Database\Eloquent\Collection given, called in /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php on line 292 in file /Users/jack/Sites/website/vendor/lab404/laravel-impersonate/src/Guard/SessionGuard.php on line 16

Stack trace:
  1. Symfony\Component\Debug\Exception\FatalThrowableError->() /Users/jack/Sites/website/vendor/lab404/laravel-impersonate/src/Guard/SessionGuard.php:16
  2. Lab404\Impersonate\Guard\SessionGuard->quietLogin() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php:292
  3. Illuminate\Auth\AuthManager->__call() /Users/jack/Sites/website/vendor/lab404/laravel-impersonate/src/Services/ImpersonateManager.php:71
  4. Lab404\Impersonate\Services\ImpersonateManager->take() /Users/jack/Sites/website/vendor/kabbouchi/nova-impersonate/src/Http/Controllers/ImpersonateController.php:36
  5. KABBOUCHI\NovaImpersonate\Http\Controllers\ImpersonateController->take() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
  6. call_user_func_array() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
  7. Illuminate\Routing\Controller->callAction() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45
  8. Illuminate\Routing\ControllerDispatcher->dispatch() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Route.php:212
  9. Illuminate\Routing\Route->runController() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Route.php:169
 10. Illuminate\Routing\Route->run() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Router.php:679
 11. Illuminate\Routing\Router->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
 12. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/nova/src/Http/Middleware/Authorize.php:18
 13. Laravel\Nova\Http\Middleware\Authorize->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 14. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 15. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/nova/src/Http/Middleware/BootTools.php:20
 16. Laravel\Nova\Http\Middleware\BootTools->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 17. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 18. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/nova/src/Http/Middleware/DispatchServingNovaEvent.php:20
 19. Laravel\Nova\Http\Middleware\DispatchServingNovaEvent->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 20. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 21. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php:43
 22. Illuminate\Auth\Middleware\Authenticate->handle() /Users/jack/Sites/website/vendor/laravel/nova/src/Http/Middleware/Authenticate.php:31
 23. Laravel\Nova\Http\Middleware\Authenticate->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 24. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 25. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41
 26. Illuminate\Routing\Middleware\SubstituteBindings->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 27. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 28. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php:49
 29. Illuminate\View\Middleware\ShareErrorsFromSession->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 30. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 31. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:63
 32. Illuminate\Session\Middleware\StartSession->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 33. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 34. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37
 35. Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 36. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 37. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:66
 38. Illuminate\Cookie\Middleware\EncryptCookies->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 39. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 40. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
 41. Illuminate\Pipeline\Pipeline->then() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Router.php:681
 42. Illuminate\Routing\Router->runRouteWithinStack() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Router.php:656
 43. Illuminate\Routing\Router->runRoute() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Router.php:622
 44. Illuminate\Routing\Router->dispatchToRoute() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Router.php:611
 45. Illuminate\Routing\Router->dispatch() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176
 46. Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
 47. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/nova/src/Http/Middleware/ServeNova.php:26
 48. Laravel\Nova\Http\Middleware\ServeNova->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 49. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 50. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php:58
 51. Barryvdh\Debugbar\Middleware\InjectDebugbar->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 52. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 53. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/app/Http/Middleware/SentryContext.php:32
 54. App\Http\Middleware\SentryContext->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 55. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 56. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/fideloper/proxy/src/TrustProxies.php:57
 57. Fideloper\Proxy\TrustProxies->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 58. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 59. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:31
 60. Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 61. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 62. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:31
 63. Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 64. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 65. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27
 66. Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 67. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 68. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62
 69. Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
 70. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 71. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
 72. Illuminate\Pipeline\Pipeline->then() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151
 73. Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter() /Users/jack/Sites/website/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
 74. Illuminate\Foundation\Http\Kernel->handle() /Users/jack/Sites/website/public/index.php:53
 75. require() /Users/jack/.composer/vendor/laravel/valet/server.php:147

This occurs after I attempt to impersonate a user (either through the index view or in details view).

The collection given appears to be the user I'm trying to impersonate, and my own user model.

I'm wondering if this is a conflict or something? All I've done is require through composer, install, then add Impersonate::make($this->id) to my Nova User model.

@KABBOUCHI
Copy link
Owner

KABBOUCHI commented Oct 19, 2018

please change it to Impersonate::make($this) and retry

@jackcruden
Copy link
Author

jackcruden commented Oct 19, 2018 via email

@KABBOUCHI
Copy link
Owner

KABBOUCHI commented Oct 19, 2018

please make sure ur custom user model has Authenticatable interface

https://github.com/laravel/laravel/blob/05e54193ba97719983a87e1944d436e8423cc1aa/app/User.php#L7-L9

@jackcruden
Copy link
Author

It does extend Authenticatable, but it seems that at some point a collection is being passed instead of the user. I cannot see where.

@KABBOUCHI
Copy link
Owner

KABBOUCHI commented Oct 19, 2018

can you debug this line?

namespace KABBOUCHI\NovaImpersonate\Http\Controllers;

check the response if $request->user() and $user_to_impersonate (https://github.com/404labfr/laravel-impersonate/blob/3b6c56a2727d5d798155bdb97ae45bc644bf83d3/src/Services/ImpersonateManager.php#L31-L41)

@jackcruden
Copy link
Author

I've narrowed this down to be likely a bug on my end. It seems that when I run App\User::find($user) where $user is a User model (not just and ID), it's for some reason returning an array of $user and my own user account. Very strange.

Will do some debugging here but I'm confident this isn't an issue with nova-impersonate.

@kendugu
Copy link
Contributor

kendugu commented Nov 2, 2018

For anyone else who finds this, I had the same issue and narrowed it down. In my case it was due to explicitly binding the route user param, for example:

Route::bind('user', function ($id) {
    return is_numeric($id)
        ? User::find($id)
        : User::where('username', $id)->firstOrFail();
});

Removing this binding fixes the issue, but I'm not sure what a solution would be to allow the explicit binding.

@KABBOUCHI
Copy link
Owner

@kendugu maybe we can rename user to id, can you submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants