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

Commit

Permalink
refactor: hide password requirements on password update (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
Highjhacker authored Apr 8, 2021
1 parent 1e55782 commit f4a8e8a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
25 changes: 17 additions & 8 deletions resources/views/profile/update-password-form.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div dusk="update-password-form">
<div x-data="{isTyping: false}" dusk="update-password-form" @updated-password.window="isTyping = false">
<div class="flex flex-col space-y-4 mt-4">
<div>
<x-ark-flash />
Expand All @@ -21,16 +21,25 @@
model="state.current_password"
:label="trans('fortify::forms.current_password')"
:errors="$errors"
class="w-full"
/>

<x-ark-input
type="password"
name="password"
model="state.password"
<x:ark-fortify::password-rules
class="w-full"
:label="trans('fortify::forms.new_password')"
:errors="$errors"
/>
:password-rules="$passwordRules"
is-typing="isTyping"
rules-wrapper-class="grid gap-4 my-4 sm:grid-cols-2 lg:grid-cols-3"
>
<x-ark-input
type="password"
name="password"
model="state.password"
class="w-full"
:label="trans('fortify::forms.new_password')"
:errors="$errors"
@keydown="isTyping=true"
/>
</x:ark-fortify::password-rules>

<x-ark-input
type="password"
Expand Down
2 changes: 1 addition & 1 deletion src/Components/UpdatePasswordForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function updatePassword(UpdatesUserPasswords $updater)
'password_confirmation' => '',
];

$this->emit('saved');
$this->dispatchBrowserEvent('updated-password');
$this->resetRules();

flash()->success(trans('fortify::pages.user-settings.password_updated'));
Expand Down
2 changes: 1 addition & 1 deletion tests/Components/UpdatePasswordFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
->set('state.password', 'abcd1234ABCD%')
->set('state.password_confirmation', 'abcd1234ABCD%')
->call('updatePassword')
->assertEmitted('saved');
->assertDispatchedBrowserEvent('updated-password');
});

it('clears password rules on update', function () {
Expand Down

0 comments on commit f4a8e8a

Please sign in to comment.