Authorizing access to the panel
"Hello everyone. I need some help, please. I'm new to Filament and I'm currently working on authentication. I'm using Filament's built-in authentication. However, I'm facing an issue I can't resolve. When a user signs up, the email verification prompt is correctly sent out. The issue is, it appears the user is already logged in since the profile and the logout option are displayed in the top right corner. I want the user to be either not logged in or to be logged out if they haven't verified their email yet. How should I proceed?"
#authorizing
6 Replies
try "MustVerifyEmail"
class User extends Authenticatable implements MustVerifyEmail, FilamentUser
I did it, but it keeps logging
class User extends Authenticatable implements MustVerifyEmail, FilamentUser
{
use HasApiTokens, HasFactory, Notifiable;
/
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
public function canAccessPanel(Panel $panel): bool
{
if ($this->is_verified == 1 && $this->hasVerifiedEmail()) {
return true;
} else if ($this->is_verified == 0 && $this->hasVerifiedEmail()) {
Notification::make()
->title('Attenzione')
->body("Al momento non hai ancora ricevuto l'autorizzazione per accedere alla piattaforma. Ti preghiamo di attendere prima di essere abilitato.")
->color('danger')
->danger()
->seconds(10)
->send();
Auth::logout();
}
return true;
}
}
Did you tried to add "verified" middleware in the ->middleware([ panel section?
No, Now I try. Thankssssss
Please, let me know
Ok, tomorrow I try. Thank you and good night