Skip to content

Commit

Permalink
Reset password
Browse files Browse the repository at this point in the history
  • Loading branch information
alexPopaCode4 committed Sep 9, 2024
1 parent 01e91f0 commit 9af3bb2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions app/Filament/Resources/UserResource/Pages/ViewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,37 @@
namespace App\Filament\Resources\UserResource\Pages;

use App\Filament\Resources\UserResource;
use Filament\Notifications\Notification;
use Filament\Pages\Actions\Action;
use Filament\Pages\Actions\EditAction;
use Filament\Resources\Pages\ViewRecord;
use Illuminate\Support\Facades\Password;

class ViewUser extends ViewRecord
{
protected static string $resource = UserResource::class;

protected function getActions(): array
{
return [
Action::make('reset_password')
->label('Reset Password')
->outlined()
->action(function () {
$response = Password::broker(config('filament-breezy.reset_broker', config('auth.defaults.passwords')))->sendResetLink(['email' => $this->getRecord()->email]);
if ($response == Password::RESET_LINK_SENT) {
Notification::make()->title(__('filament-breezy::default.reset_password.notification_success'))->success()->send();

$this->hasBeenSent = true;
} else {
Notification::make()->title(match ($response) {
'passwords.throttled' => __('passwords.throttled'),
'passwords.user' => __('passwords.user')
})->danger()->send();
}
}),

EditAction::make(),
];
}
}

0 comments on commit 9af3bb2

Please sign in to comment.