mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 14:04:45 +02:00
Reimplement password reset (#1182)
* add password reset to all panels * remove old leftovers * fix reset url in account created mail
This commit is contained in:
parent
7471347b55
commit
a768fadaea
@ -31,7 +31,6 @@ use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
|||||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||||
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
||||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||||
use App\Notifications\SendPasswordReset as ResetPasswordNotification;
|
|
||||||
use ResourceBundle;
|
use ResourceBundle;
|
||||||
use Spatie\Permission\Traits\HasRoles;
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
|
|
||||||
@ -201,21 +200,6 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
|||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send the password reset notification.
|
|
||||||
*
|
|
||||||
* @param string $token
|
|
||||||
*/
|
|
||||||
public function sendPasswordResetNotification($token): void
|
|
||||||
{
|
|
||||||
Activity::event('auth:reset-password')
|
|
||||||
->withRequestMetadata()
|
|
||||||
->subject($this)
|
|
||||||
->log('sending password reset email');
|
|
||||||
|
|
||||||
$this->notify(new ResetPasswordNotification($token));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function username(): Attribute
|
public function username(): Attribute
|
||||||
{
|
{
|
||||||
return Attribute::make(
|
return Attribute::make(
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Notifications;
|
namespace App\Notifications;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
@ -29,7 +30,7 @@ class AccountCreated extends Notification implements ShouldQueue
|
|||||||
->line('Email: ' . $notifiable->email);
|
->line('Email: ' . $notifiable->email);
|
||||||
|
|
||||||
if (!is_null($this->token)) {
|
if (!is_null($this->token)) {
|
||||||
return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($notifiable->email)));
|
return $message->action('Setup Your Account', Filament::getResetPasswordUrl($this->token, $notifiable));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $message;
|
return $message;
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Notifications\Notification;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
|
||||||
|
|
||||||
class SendPasswordReset extends Notification implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Queueable;
|
|
||||||
|
|
||||||
public function __construct(public string $token) {}
|
|
||||||
|
|
||||||
/** @return string[] */
|
|
||||||
public function via(): array
|
|
||||||
{
|
|
||||||
return ['mail'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toMail(User $notifiable): MailMessage
|
|
||||||
{
|
|
||||||
return (new MailMessage())
|
|
||||||
->subject('Reset Password')
|
|
||||||
->line('You are receiving this email because we received a password reset request for your account.')
|
|
||||||
->action('Reset Password', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($notifiable->email)))
|
|
||||||
->line('If you did not request a password reset, no further action is required.');
|
|
||||||
}
|
|
||||||
}
|
|
@ -39,6 +39,7 @@ class AdminPanelProvider extends PanelProvider
|
|||||||
->topNavigation(config('panel.filament.top-navigation', true))
|
->topNavigation(config('panel.filament.top-navigation', true))
|
||||||
->maxContentWidth(config('panel.filament.display-width', 'screen-2xl'))
|
->maxContentWidth(config('panel.filament.display-width', 'screen-2xl'))
|
||||||
->login(Login::class)
|
->login(Login::class)
|
||||||
|
->passwordReset()
|
||||||
->userMenuItems([
|
->userMenuItems([
|
||||||
'profile' => MenuItem::make()
|
'profile' => MenuItem::make()
|
||||||
->label(fn () => trans('filament-panels::pages/auth/edit-profile.label'))
|
->label(fn () => trans('filament-panels::pages/auth/edit-profile.label'))
|
||||||
|
@ -37,6 +37,7 @@ class AppPanelProvider extends PanelProvider
|
|||||||
->navigation(false)
|
->navigation(false)
|
||||||
->profile(EditProfile::class, false)
|
->profile(EditProfile::class, false)
|
||||||
->login(Login::class)
|
->login(Login::class)
|
||||||
|
->passwordReset()
|
||||||
->userMenuItems([
|
->userMenuItems([
|
||||||
MenuItem::make()
|
MenuItem::make()
|
||||||
->label('Admin')
|
->label('Admin')
|
||||||
|
@ -42,6 +42,7 @@ class ServerPanelProvider extends PanelProvider
|
|||||||
->topNavigation(config('panel.filament.top-navigation', true))
|
->topNavigation(config('panel.filament.top-navigation', true))
|
||||||
->maxContentWidth(config('panel.filament.display-width', 'screen-2xl'))
|
->maxContentWidth(config('panel.filament.display-width', 'screen-2xl'))
|
||||||
->login(Login::class)
|
->login(Login::class)
|
||||||
|
->passwordReset()
|
||||||
->userMenuItems([
|
->userMenuItems([
|
||||||
'profile' => MenuItem::make()
|
'profile' => MenuItem::make()
|
||||||
->label(fn () => trans('filament-panels::pages/auth/edit-profile.label'))
|
->label(fn () => trans('filament-panels::pages/auth/edit-profile.label'))
|
||||||
|
@ -11,7 +11,6 @@ return [
|
|||||||
'fail' => 'Failed log in',
|
'fail' => 'Failed log in',
|
||||||
'success' => 'Logged in',
|
'success' => 'Logged in',
|
||||||
'password-reset' => 'Password reset',
|
'password-reset' => 'Password reset',
|
||||||
'reset-password' => 'Requested password reset',
|
|
||||||
'checkpoint' => 'Two-factor authentication requested',
|
'checkpoint' => 'Two-factor authentication requested',
|
||||||
'recovery-token' => 'Used two-factor recovery token',
|
'recovery-token' => 'Used two-factor recovery token',
|
||||||
'token' => 'Solved two-factor challenge',
|
'token' => 'Solved two-factor challenge',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user