© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
17 replies
karpadiem

CanAccessPanel logic causing 403 error for livewire.update on Tenant Registration Form

Dealing with an issue that I think comes down to inexperience.

In my development environment, I am working on my logic for what panels a user has access to.

in my user model, i have these functions:
public function canAccessPanel(Panel $panel): bool
    {
        //if panel is admin, only saas employees can access
        if($panel->getId() === 'admin'){
            return $this->canAccessAdminPanel();
        }elseif ($panel->getId() === 'company') {
            return $this->canAccessCompanyPanel();
        }
        return false;
    }

    public function canAccessAdminPanel(): bool
    {
        return $this->isSaasEmployee();
    }

public function canAccessCompanyPanel(): bool
    {

        // Check if user is a SAAS employee
        if ($this->isSaasEmployee()) {
            return true;
        }

        // Check if user is associated with any companies
        if ($this->companies()->exists()) {
            return true;
        }

        return false;
public function canAccessPanel(Panel $panel): bool
    {
        //if panel is admin, only saas employees can access
        if($panel->getId() === 'admin'){
            return $this->canAccessAdminPanel();
        }elseif ($panel->getId() === 'company') {
            return $this->canAccessCompanyPanel();
        }
        return false;
    }

    public function canAccessAdminPanel(): bool
    {
        return $this->isSaasEmployee();
    }

public function canAccessCompanyPanel(): bool
    {

        // Check if user is a SAAS employee
        if ($this->isSaasEmployee()) {
            return true;
        }

        // Check if user is associated with any companies
        if ($this->companies()->exists()) {
            return true;
        }

        return false;


Simple enough. Does what it is supposed to. However, I ran into problems. Because a newly registered user is not associated with a tenant yet, the user was not able to access the company/new page to create a tenant. Additionally, I realized they couldn't access the /company/logout page. Each presented with a 403 error.

This is where I worry I'm messing up. I added some exceptions based on routes:
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

ComponentNotFoundException on Tenant Registration
FilamentFFilament / ❓┊help
3y ago
Customize registration logic
FilamentFFilament / ❓┊help
9mo ago
Tenancy: access tenant in `canAccessPanel` function
FilamentFFilament / ❓┊help
3y ago
Filament canAccessPanel error
FilamentFFilament / ❓┊help
6mo ago