Solution
Add this method to app/Actions/Fortify/CreateNewUser.php
file.
use Illuminate\Validation\Rules\Password;
// ...
protected function passwordRules()
{
return ['required', 'string', Password::default()];
}
If you are using Jetstream
, you should also remove these line in resources/views/auth/register.blade.php
<div class="mt-4">
<x-jet-label for="password_confirmation" value="{{ __('Confirm Password') }}" />
<x-jet-input id="password_confirmation" class="block mt-1 w-full" type="password" name="password_confirmation" required autocomplete="new-password" />
</div>
Explanation
Fortify has an action class which is responsible for user creation.
You can find it at app/Actions/Fortify/CreateNewUser.php
.
You can see the line:
'password' => $this->passwordRules(),
Under hood it uses passwordRules
method from PasswordValidationRules
trait. That method returns array with confirmed
element:
return ['required', 'string', Password::default(), 'confirmed'];
confirmed
is a rule responsible for email confirmation, so we made our own passwordRules
method which doesn't has confirmed
rule.
Top comments (3)
Also probably worth mentioning that you have to import Laravel\Fortify\Rules\Password; into your Action.
Thank you for taking time to put this out. This was useful.
Glad you liked it!