Login auth check if user is admin

Hi, I added a bool value "is_admin" to the users to check, if the user is allowed to login to the backend. Now, I want to integrate the check, but I don't know how I should do that. Why? I want to use the users table to interact with user values in the frontend. some users are admins and should be able to login to the backend. It might be possible to remove admin-status of several users or add the admin status.
Solution:
``` public function canAccessPanel(Panel $panel): bool { return $this->is_admin; }...
Jump to solution
9 Replies
hyperion-mx
hyperion-mxβ€’2mo ago
when you say "Allowed to login to backend" you mean if you allow them access to Filament Panel?
TheSoulrester
TheSoulresterOPβ€’2mo ago
Isn't it so that every user in the user table with password will be allowed to login to filament backend?
hyperion-mx
hyperion-mxβ€’2mo ago
yes and you can decide which one can and which one can not based on any logic you want on the User model implement FilamentUser and implement the method
public function canAccessPanel(Panel $panel): bool
{
// here decide your logic if they can access or not
}
public function canAccessPanel(Panel $panel): bool
{
// here decide your logic if they can access or not
}
hyperion-mx
hyperion-mxβ€’2mo ago
in your case you can do
Solution
hyperion-mx
hyperion-mxβ€’2mo ago
public function canAccessPanel(Panel $panel): bool
{
return $this->is_admin;
}
public function canAccessPanel(Panel $panel): bool
{
return $this->is_admin;
}
TheSoulrester
TheSoulresterOPβ€’2mo ago
ohhh well, I will try this out. My coding skills are not the best. I am still learning laravel and filament πŸ˜‰
hyperion-mx
hyperion-mxβ€’2mo ago
no worries
TheSoulrester
TheSoulresterOPβ€’2mo ago
thank you! πŸ˜„
public function canAccessPanel(Panel $panel): bool { return $this->is_admin; }
Want results from more Discord servers?
Add your server