404labfr / laravel-impersonate

Laravel Impersonate is a plugin that allows you to authenticate as your users.
https://marceau.casals.fr
1.99k stars 201 forks source link

[Laravel v8.72] Method getRecallerName does not exist #145

Open relaypilot opened 2 years ago

relaypilot commented 2 years ago

After upgrading from Laravel v8.71.x to Laravel v8.72.0, it became impossible to impersonate users. When I try to impersonate a user, I am simply logged out.

My log files show the following:

Method Illuminate\Auth\RequestGuard::getRecallerName does not exist.

    {
        "userId":1,
        "exception":"[object] (BadMethodCallException(code: 0): Method Illuminate\\Auth\\RequestGuard::getRecallerName does not exist. at /home/app-123/vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:113
    )

It seems that the new Laravel version 8.72 contains a breaking change for the laravel-impersonate package.

Vicftz commented 2 years ago

Same issue here! Did you find a quick fix ? (Downgrade Laravel version ?)

relaypilot commented 2 years ago

Downgrading to 8.71 worked on local but not on prod for some reason.

A quick solution I found is to comment out those lines in src/Illuminate/Routing/SortedMiddleware.php

    $parents = @class_parents($stripped);

    if ($parents !== false) {
        foreach ($parents as $parent) {
            yield $parent;
        }
    }

https://github.com/laravel/framework/compare/v8.71.0...v8.72.0

Vicftz commented 2 years ago

I change my composer.json to this : "laravel/framework": "=8.71.0"

Work locally on in production in my side !