Comments (3)
Multi-tenancy can be implemented in 100 different ways. I don't know how yours works, I can't tell you what needs to be handled.
The underlying impersonate package does fire some events when impersonation happens, maybe you can listen for those events and wire up the appropriate tenant that way?
https://github.com/404labfr/laravel-impersonate?tab=readme-ov-file#events
from filament-impersonate.
in my case, I have 2 panels, one with multi-tenancy and the other without. When I impersonate a user that does not belong to a tenant, I get memory leak. Then I added the user to a tenant and then it worked as normal.
from filament-impersonate.
Hey @altomar
I did not hit the memory issues but here is what worked for me in case it helps you.
In your web.php, define a custom route for impersonate.
Route::get('/impersonate/{user}', ImpersonateController::class)->name('impersonate');
Create the ImpersonateController.
use App\Models\User;
use Filament\Support\Concerns\EvaluatesClosures;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use STS\FilamentImpersonate\Concerns\Impersonates;
class ImpersonateController extends Controller
{
use EvaluatesClosures; // We need this trait in order use the impersonate feature from the plugin
use Impersonates;
public function __invoke(Request $request, User $user): RedirectResponse
{
abort_unless(auth()->check() && auth()->user()->is_admin, 403);
return $this->impersonate($user); // we are using the function from the plugin.
}
}
Finally in UserResource, pass the custom url to Impersonate action.
->actions([
Impersonate::make()
->url(fn (User $record) => route('impersonate', $record)),
])
from filament-impersonate.
Related Issues (20)
- Problem to impersonate with admin guard HOT 7
- Error on impersionate HOT 4
- Display issue HOT 8
- Error on redirect FilamentManager::getUserName() HOT 3
- Auto mode not working properly
- registerRenderHook(): Argument #1 ($name) must be of type string, null given HOT 6
- Banner hidden by my navbar HOT 1
- Trapped in exception when impersonating soft-deleted user HOT 1
- Table Impersonate does not work with widgets HOT 2
- Trouble on impersonate from resources other than UserResource HOT 5
- Add Laravel 11 support HOT 4
- ImpersonateManager does not leave the impersonation HOT 5
- localize HOT 1
- Always impersonating myself HOT 1
- Error 403 Forbidden when clicked from table actions HOT 2
- ViewException: Filament\FilamentManager::getUserName() HOT 2
- Issues with custom middleware HOT 1
- Cancel button not working after coming back from impersonation HOT 1
- multipanel redirect HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from filament-impersonate.