Forbidden after registration

hi all, my App Panel look like this:
...
class AgencyPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('agency')
->path('agency')
->darkMode(false)
->login()
->registration(Register::class)
->passwordReset()
->profile()

...
...
class AgencyPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('agency')
->path('agency')
->darkMode(false)
->login()
->registration(Register::class)
->passwordReset()
->profile()

...
and inside model User i use MustVerifyEmail why after registration i obtain a 403 Forbidden page and even after i click on email verification ? thanks
11 Replies
toeknee
toeknee3mo ago
Have you setup the canAcceePanel on the user model
pr3slaff
pr3slaff3mo ago
if its production env, you should implement FilamentUser on User model and create canAccessPanel method
ocram82
ocram823mo ago
yes i have a canAccessPanel method. here it is :
public function canAccessPanel(Panel $panel): bool
{

if ($panel->getId() == 'admin') {

return $this->isAdmin() && $this->hasVerifiedEmail();

} elseif ($panel->getId() == 'agency') {

return $this->email == $this->hasVerifiedEmail() && $this->hasRole('agency');

}

}

public function isAdmin()
{
return $this->email == config('auth.demo_seed_admin_account.email');
}
public function canAccessPanel(Panel $panel): bool
{

if ($panel->getId() == 'admin') {

return $this->isAdmin() && $this->hasVerifiedEmail();

} elseif ($panel->getId() == 'agency') {

return $this->email == $this->hasVerifiedEmail() && $this->hasRole('agency');

}

}

public function isAdmin()
{
return $this->email == config('auth.demo_seed_admin_account.email');
}
toeknee
toeknee3mo ago
And for the option being hit, what is the response? Is it false as that would cause your 403
ocram82
ocram823mo ago
i've just put dd here:
public function canAccessPanel(Panel $panel): bool
{

if ($panel->getId() == 'admin') {

return $this->isAdmin() && $this->hasVerifiedEmail();

} elseif ($panel->getId() == 'agency') {
dd('here!!!);
return $this->email == $this->hasVerifiedEmail() && $this->hasRole('agency');

}

}
public function canAccessPanel(Panel $panel): bool
{

if ($panel->getId() == 'admin') {

return $this->isAdmin() && $this->hasVerifiedEmail();

} elseif ($panel->getId() == 'agency') {
dd('here!!!);
return $this->email == $this->hasVerifiedEmail() && $this->hasRole('agency');

}

}
and that was hitted. But if i delete dd i obtain 403 Forbidden. Another info: after i click the email confirmation link i obtain a 403 Forbidden
toeknee
toeknee3mo ago
Do DD return $this->email == $this->hasVerifiedEmail() && $this->hasRole('agency');
dd($this->email == $this->hasVerifiedEmail() && $this->hasRole('agency'));
dd($this->email == $this->hasVerifiedEmail() && $this->hasRole('agency'));
is it false by any chance.
ocram82
ocram823mo ago
just done, this is false yes
toeknee
toeknee3mo ago
There is your problem. So dump on each till you see what the cause is as filament is working, your checks are doing what they are coded to do.
ocram82
ocram823mo ago
but after registration i suppose that would be false. But the werid thing is after click the "email verification" button yes, maybe i have to present the user a custom thank you page after registration telling him to check his mailbox. But after email verification is very strange....anyway check better and give you a feedback
toeknee
toeknee3mo ago
Welcome
ocram82
ocram823mo ago
to make the things work. I do this:
public function canAccessPanel(Panel $panel): bool
{

if ($panel->getId() == 'admin') {

return $this->isAdmin() && $this->hasVerifiedEmail();

} else{

return true;

}

}
public function canAccessPanel(Panel $panel): bool
{

if ($panel->getId() == 'admin') {

return $this->isAdmin() && $this->hasVerifiedEmail();

} else{

return true;

}

}
Want results from more Discord servers?
Add your server
More Posts