Skip to content

Commit

Permalink
fix update password #12
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Jan 28, 2023
1 parent 5b251d8 commit 284d77a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@ public static function form(Form $form): Form
Forms\Components\TextInput::make('password')->label(trans('filament-user::user.resource.password'))
->password()
->maxLength(255)
->dehydrateStateUsing(static function ($state){
->dehydrateStateUsing(static function ($state) use ($form){
if(!empty($state)){
return Hash::make($state);
}
}),

$user = User::find($form->getColumns());
if($user){
return $user->password;
}
}),
];

if(config('filament-user.shield')){
Expand Down
7 changes: 6 additions & 1 deletion stubs/UserResource.stub
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@ class UserResource extends Resource
Forms\Components\TextInput::make('password')->label(trans('filament-user::user.resource.password'))
->password()
->maxLength(255)
->dehydrateStateUsing(static function ($state){
->dehydrateStateUsing(static function ($state) use ($form){
if(!empty($state)){
return Hash::make($state);
}

$user = User::find($form->getColumns());
if($user){
return $user->password;
}
}),
];

Expand Down

0 comments on commit 284d77a

Please sign in to comment.