Redirect to Profile On UsersRessource
Am trying to redirect the user to his own profile if he's trying to view or edit his own record on UsersRessource
Am hiding his record with
ModifyQueryUsing on $table on UsersRessource
But a user can just edit the URL to access his resources
(Not talking about Authorisation)
I want to redirect to the Profile page if the user tries to view or edit his own User Model
Any help ?
3 Replies
On second thought, i think if someone is trying to be a hacker, he's not willing to go to his Profile..
I ll Stick to 403
But it would be nice to know how to do it
if you're using filament panels you can set up a policy for your users it will be something like
this is pretty the same with other gates like edit, delete, ... and it will be automatically applied if you're using panels as said above
else if you don't use panels you can still set up policies but you'd have to check if they can do whatever things they want to do
to check just do something like
auth()->user()->can('viewAny', User::class)
, auth()->user()->can('view', $record)
I solved it by Overriding the authorizeAccess method on EditUser Class
to check if the user is trying to Edit his own Record Before actually testing the Authorization part , then redirect to the EditProfilePage Class ( from Joaopaulolndev\FilamentEditProfile Plugin )
the other part is treated om the UserPolicy.php as @skyrowl refered