404labfr / 404labfr/laravel-impersonate

Impersonation URL 403s after impersonate

Open
#72 7 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
PHP
Stars
2.3k
Forks
235
PR merge metrics
No merged PRs in 30d

Description

I'm using latest version of Laravel (5.8) and your package. I've installed using the route macro `Route::impersonate()` and have the following in my User model:

```
/**
* @return bool
*/
public function canImpersonate()
{
// For example
return $this->hasRole('admin');
}
```

`hasRole` is part of the very popular [Spatie Laravel Persmissions package](https://github.com/spatie/laravel-permission).

When logged in as an admin, if I visit the route created by your package I'm taken to: /impersonate/take/3

This page 403s. However, when I then visit / I find I'm logged in as the impersonated user (expected behaviour). It looks like the impersonation is potentially being run before middleware or that something else is going on? The route macro is outside of any groups or middleware.

/impersonate/leave works exactly as expected and redirects me correctly.

Any ideas how I can solve this?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.