Filament provides an integrated feature for users to change their password. In this article, I'll show you how to set it up.
By default, a user's profile looks like this:
At the very top is the username, which has no additional functionality. Below that is the appearance switcher. And at the bottom is the logout button.
Now we'll implement the password change functionality together.
1. Activation in AdminPanelProvider
use Filament\Panel;
use Filament\PanelProvider;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->profile() // Activates the profile featureNow it looks like this:
The profile field is now clickable and leads to a profile page that looks like this:
Here, users can change their name, email, and password.
Once the password is entered, another field appears to confirm the password.
Profile-Page with Password Confirmation
2. Customize Menu Items
The menu items can be customized according to individual preferences, like this:
->profile()
->userMenuItems([
'profile' => MenuItem::make()
->icon('heroicon-o-user-circle')
->label('Edit Profile'),
])With the example code, it looks like this:
Features
Users can change their own password
Current password verification
New password confirmation
Uses Laravel's Password Validation Rules by default
Conclusion
Filament's password change feature provides users with a secure way to change their password. Try it in your next project.
Standard
With profile() method
Profile-Page
Customized Menu Items