stechstudio / filament-impersonate Goto Github PK
View Code? Open in Web Editor NEWFilament plugin that makes it easy to impersonate your users
Filament plugin that makes it easy to impersonate your users
Hi,
In the latest update, when i run php artisan route:cache I will get this exception:
Cannot declare class STS\FilamentImpersonate\Impersonate, because the name is already in use when caching route
Hi there,
I noticed this package isn't visible in the Filament plugins directory? You can submit it here: https://github.com/filamentphp/filamentphp.com/blob/main/README.md#contributing
I have an issue to display the banner . I have investigated the code. I found that the issue lies in the following file:
In the original code snippet, the Filament::registerRenderHook method is used as follows:
Filament::registerRenderHook(
'body.start',
static fn (): string => Blade::render("<x-filament-impersonate::banner/>")
);
To resolve the issue, you can change it to the following code:
FilamentView::registerRenderHook(
'panels::body.start',
static fn (): string => Blade::render("<x-filament-impersonate::banner/>")
);
If you're okay with it, I can create a pull request to implement the changes.
Let me know what you think.
By the way, thank you for your plugin
Is it possible to add Laravel 9 support?
lab404/laravel-impersonate
needs to be bumped up?
Thank you!
I am unable to get this plugin to work in Filament Admin Panel v2.
Would love to get a hint on how to proceed.
I attempted to impersonate a soft-deleted user, which ends up trapping me in the following exception:
Filament\FilamentManager::getUserName(): Argument #1 ($user) must be of type Illuminate\Database\Eloquent\Model|Illuminate\Contracts\Auth\Authenticatable, null given
in reference to
<x-filament-impersonate::banner/>
I understand why this is probably happening; the intended $user is not being hydrated ->withTrashed()
applied. Where exactly do I go to customize the banner, given that in the current version, it is being injected via a render hook? i.e., I did not place x-impersonate::banner
into my master layout.
Temporary solution to break out of the exception was to set FILAMENT_IMPERSONATE_BANNER_RENDER_HOOK=""
in .env so that I could log back in.
I'm on Laravel 11
When I click Leave
in the banner, nothing happens.
I've narrowed it down to the ImpersonateManager
leave
method not working.
Which as to do with the package this package uses.
Get this error message when I try to impersonate a user.
Call to undefined method Filament\FilamentManager::getCurrentPanel()
- Using jetstream. Livewire 2 - any idea?
div.fi-layout > aside.fi-sidebar {
padding-{{ $position }}: var(--impersonate-banner-height);
}
This line of code cause an issues with the filament sidebar, it create a gap between the sidebar and the impersonate banner.
I'm using the default setup/configuration of the plugin.
Disabling the Css it fixed the issue or if the position
setting is top
then the css will not be applied.
Hi,
When i click Impersonate from table actions I get
Error 403 Forbidden I assume because the url stays the same mysite.test/admin/users
When I click Impersonate from Edit view everything works normally
Laravel: 11.10.0
PHP 8.2.19
Filament: v3.2.86
Thanks for your help and support
use STS\FilamentImpersonate\Tables\Actions\Impersonate;
class UserResource extends Resource
->actions([
Impersonate::make(),
EditAction::make(),
ActionGroup::make([
ViewAction::make(),
EditAction::make(),
DeleteAction::make(),
Impersonate::make(),
]),
])
config file
<?php
return [
// This is the guard used when logging in as the impersonated user.
'guard' => env('FILAMENT_IMPERSONATE_GUARD', 'web'),
// After impersonating this is where we'll redirect you to.
'redirect_to' => env('FILAMENT_IMPERSONATE_REDIRECT', '/admin'),
// We wire up a route for the "leave" button. You can change the middleware stack here if needed.
'leave_middleware' => env('FILAMENT_IMPERSONATE_LEAVE_MIDDLEWARE', 'web'),
'banner' => [
// Available hooks: https://filamentphp.com/docs/3.x/support/render-hooks#available-render-hooks
'render_hook' => env('FILAMENT_IMPERSONATE_BANNER_RENDER_HOOK', 'panels::body.start'),
// Currently supports 'dark', 'light' and 'auto'.
'style' => env('FILAMENT_IMPERSONATE_BANNER_STYLE', 'dark'),
// Turn this off if you want `absolute` positioning, so the banner scrolls out of view
'fixed' => env('FILAMENT_IMPERSONATE_BANNER_FIXED', true),
// Currently supports 'top' and 'bottom'.
'position' => env('FILAMENT_IMPERSONATE_BANNER_POSITION', 'top'),
'styles' => [
'light' => [
'text' => '#1f2937',
'background' => '#f3f4f6',
'border' => '#e8eaec',
],
'dark' => [
'text' => '#f3f4f6',
'background' => '#1f2937',
'border' => '#374151',
],
]
],
];
In the doc it says use IsFilamentUser
, but I get the message Undefined type 'App\Models\IsFilamentUser'.
and it can't find anything to import. It seems to work without IsFilamentUser
, but am I doing anything wrong or is the example wrong?
class User implements FilamentUser {
use IsFilamentUser;
public function canImpersonate()
{
return true;
}
}
Clicking on the impersonate button/icon cause a RouteNotFoundException "Route [filament.auth.login] not defined" in routes/web.php
In banner component, if auto is set, it only appears light mode.
$flipped variable is not set anywhere.
In the last couple of days I noticed that when I go to impersonate any user, it "impersonates" the user I'm signed in with. Then when I "Leave" it 500 errors and I'm stuck until logging out. This plugin was working 100% perfectly until this so I'm sure I probably messed something up.
Any insight into how I should troubleshoot this issue would be greatly appreciated.
Thanks in advance.
Right now this is only available as a table action. Would be nice to be available as a page action as well, so it could be added to a View User page, for example.
During composer update to 3.6 this error
Filament\Support\Facades\FilamentView::registerRenderHook(): Argument #1 ($name) must be of type string, null given, called in /app/vendor/stechstudio/filament-impersonate/src/FilamentImpersonateServiceProvider.php on line 40
Impersonate stopped working after I updated Laravel. I was on Laravel 9.3.1 and it worked and after updating to 9.6.0 I just get logged out when I click on the impersonate button. Any ideas why? Impersonate, Filament and Jetstream are all on latest versions.
I found two things that seems to "fix" this. One is removing this line from App\Http\Kernel.php
... \Laravel\Jetstream\Http\Middleware\AuthenticateSession::class,
and the other is changing Route::middleware(['auth:sanctum', 'verified'])
to Route::middleware(['auth:web', 'verified'])
in my routes file. Does anyone know the implications of doing any of those options?
Thank you!
When redirect I'm getting this error:
Filament\FilamentManager::getUserName(): Argument #1 ($user) must be of type Illuminate\Database\Eloquent\Model|Illuminate\Contracts\Auth\Authenticatable, null given, called in /Users/daniel/Desktop/Proyectos/tickify/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 353
<x-filament-impersonate::banner/>
how to share localization files?
When adding the impersonate Action to a Group like so:
->actions([
ActionGroup::make([
ViewAction::make(),
EditAction::make(),
DeleteAction::make(),
Impersonate::make()->redirectTo('/admin'),
]),
]);
the styling isn't the same, nor does the label appear:
Is this caused by my incorrect usage of the plugin or is it a bug?
I have a resource named InstructorResource
. The Instructor
model has a relational user
method which belongs to User
model.
I am trying to impersonate from InstructorResource by:
return $table
->actions([
Impersonate::make()
->redirectTo('/instructor'),
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
]),
From the UserResource
class, it is working perfectly though. Is it possible to impersonate from InstructResource
?
I'm seeing this error on a testing server:
Filament\FilamentManager::getUserName(): Argument #1 ($user) must be of type Illuminate\Database\Eloquent\Model|Illuminate\Contracts\Auth\Authenticatable, null given, called in /home/forge/mysite.ie/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 355 (View: /home/forge/mysite.ie/vendor/stechstudio/filament-impersonate/resources/views/components/banner.blade.php) (View: /home/forge/mysite.ie/vendor/stechstudio/filament-impersonate/resources/views/components/banner.blade.php) (View: /home/forge/mysite.ie/vendor/stechstudio/filament-impersonate/resources/views/components/banner.blade.php) (View: /home/forge/mysite.ie/vendor/stechstudio/filament-impersonate/resources/views/components/banner.blade.php) (View: /home/forge/mysite.ie/vendor/stechstudio/filament-impersonate/resources/views/components/banner.blade.php)
I was impersonating a user when I re-migrated the database.
I think it's to do with session cookies. If I open an incognito browser then everything is fine.
Not sure what the solution is...
Currently, package can't be installed on Laravel 11.
Hi, could you bump the version to support Laravel 10?
I am trying to add impersonate to multi-tenant app. when i hit impersonate action it throws 403 error.
FILAMENT_IMPERSONATE_REDIRECT=/console
Also tried FILAMENT_IMPERSONATE_REDIRECT=/console/1
to see if it cannot find the tenant or something but no luck.
Tried to pass a custom url to redirectTo()
method and also tried to set tenant before redirecting but still does not work.
Am i missing something that should be added to make it work on multi-tenant?
I have a navbar on the page that is fixed to the top. When impersonating someone, the impersonate::banner is also fixed to the top and behind the navbar. How can I make it appear below my navbar?
I tried assigning a style of top: 60px;
, but that didn't work.
Thanks!
It seems that this plugin isn't working properly with Laravel Octane (https://laravel.com/docs/10.x/octane).
I have an existing project where I use your plugin since you released it. Now we switched to laravel Octane (with roadrunner) on Production, and a user still can impersonate, but the top bar to end the Impersonate isn't displayed.
I can reproduce this on local system as well. I login+impersonate:
php artisan serve
everything works as expected.php artisan octane:start
every thing works, except I cant see the impersonate bar.Any ideas? Does this package use any static class properties or something? See https://laravel.com/docs/10.x/octane#dependency-injection-and-octane
Btw: Thanks for your great package!
Hello,
If you have a table in which there are widgets that interact with the table(InteractsWithPageTable
) when executing the impersonate action another widget event is sent, which causes that the user is not redirected correctly.
Do you know any way to stop this from happening?
Best regards
using this package with two guards "web" (those my website users) and "admins" (filament users)
and added this package to both.
the problem is when impersonating "web", it works well.
but when trying to impersonate "admins" guard, it just picks the same id in guard "web"
lost? me too 😂.
so in admins table
and in users table
when i click impersonate on admin2, it impersonate user2 instead.
auth.php
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'clients',
],
'admins' => [
'driver' => 'session',
'provider' => 'admins',
],
],
Hi,
Many thanks for this package. It would be great if the banner style automatically switches when filament dark mode is enabled and toggled.
Hello, I'm a new Filament user so please excuse me if this is actually entirely my fault!
I've followed the steps to install the package and it works great, except that when I click on the "Leave" button on the banner, the app crashes with the following error.
Symfony\Component\HttpFoundation\Response::setContent(): Argument #1 ($content) must be of type ?string, Illuminate\Routing\Redirector given, called in /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Response.php on line 72
I tried setting a different redirect with the backTo()
method, and through the .env
file but neither worked.
Any idea why this might be happening?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.