Skip to content

Commit

Permalink
feat(librarium): Reset password action (#888)
Browse files Browse the repository at this point in the history
* feat(librarium): added Password Reset button

* feat(librarium): implement password reset action closes #816
  • Loading branch information
MathewEm authored Dec 30, 2024
1 parent a71ca33 commit 0cc1544
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
7 changes: 5 additions & 2 deletions app/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ public static function form(Form $form): Form
->hidden(fn ($record) => $record && ! $record->email_verified_at)
->onColor('success'),
Forms\Components\Actions::make([
Forms\Components\Actions\Action::make('reset_password')
->label('Send Password Reset Email')
->action('sendPasswordReset'),
Forms\Components\Actions\Action::make('verify_email')
->label('Activate & Verify')
->hidden(fn ($record) => $record && $record->email_verified_at)
->label('Activate User & Verify Email')
->disabled(fn ($record) => isset($record->email_verified_at))
->action('setVerifiedEmail'),
]),
]),
Expand Down
18 changes: 18 additions & 0 deletions app/Filament/Resources/UserResource/Pages/EditUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use App\Filament\Resources\UserResource;
use Filament\Actions;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Support\Facades\Password;

class EditUser extends EditRecord
{
Expand Down Expand Up @@ -61,5 +63,21 @@ public function setVerifiedEmail(): void
}
$this->record->markEmailAsVerified();
$this->refreshFormData(['active']);
Notification::make()
->title('User\'s email is verified!')
->success()
->send();
}

/**
* Call the Reset Password Email process
*/
public function sendPasswordReset(): void
{
Password::sendResetLink(['email' => $this->data['email']]);
Notification::make()
->title('Reset password email sent!')
->success()
->send();
}
}
3 changes: 0 additions & 3 deletions resources/src/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,6 @@ declare global {
// @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
import('vue')
// @ts-ignore
export type { Locale } from './stores/LocaleStore'
import('./stores/LocaleStore')
}

// for vue template auto import
Expand Down

0 comments on commit 0cc1544

Please sign in to comment.