-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed reset password route as it was unnecessary.
Renamed PasswordResetController -> PasswordResetService. Simplified sendResetLink.
- Loading branch information
1 parent
c4d1bb4
commit b23255d
Showing
4 changed files
with
40 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Chiiya\FilamentAccessControl\Services; | ||
|
||
use Chiiya\FilamentAccessControl\Models\FilamentUser; | ||
use Filament\Facades\Filament; | ||
use Illuminate\Support\Facades\Password; | ||
use Filament\Notifications\Auth\ResetPassword as ResetPasswordNotification; | ||
use Filament\Notifications\Notification; | ||
use Exception; | ||
|
||
class PasswordResetService | ||
{ | ||
public function sendResetLink(FilamentUser $user) | ||
{ | ||
try { | ||
$token = Password::broker('filament')->createToken($user); | ||
|
||
// Create the notification and set the URL | ||
$notification = new ResetPasswordNotification($token); | ||
$notification->url = Filament::getResetPasswordUrl($token, $user); | ||
|
||
// Send the notification | ||
$user->notify($notification); | ||
|
||
Notification::make() | ||
->title(__('Password reset link sent!')) | ||
->success() | ||
->send(); | ||
} catch (Exception $e) { | ||
Notification::make() | ||
->title($e->getMessage()) | ||
->danger() | ||
->send(); | ||
} | ||
} | ||
} |