Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
fix: add null check before validating password (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsANameToo authored Mar 24, 2021
1 parent d725042 commit 9fb6752
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Components/Concerns/ValidatesPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ trait ValidatesPassword

public function updatedStatePassword($password)
{
if (is_null($password)) {
return;
}

$this->errorMessages = [];

$passwordValidator = (new Password())
Expand Down
24 changes: 24 additions & 0 deletions tests/Components/UpdatePasswordFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,27 @@
'needsMinimumLength' => false,
]);
});

it('handles password being null', function () {
$user = createUserModel();

Livewire::actingAs($user)
->test(UpdatePasswordForm::class)
->assertSet('state', [
'current_password' => '',
'password' => '',
'password_confirmation' => '',
])
->assertViewIs('ark-fortify::profile.update-password-form')
->set('state.current_password', 'password')
->set('state.password', null)
->set('state.password_confirmation', null)
->call('updatePassword')
->assertSet('passwordRules', [
'needsLowercase' => false,
'needsUppercase' => false,
'needsNumeric' => false,
'needsSpecialCharacter' => false,
'needsMinimumLength' => false,
]);
});

0 comments on commit 9fb6752

Please sign in to comment.