DEV Community

Ostap Brehin
Ostap Brehin

Posted on β€’ Edited on

5 1

Fortify: How to disable password confirmation field (Jetstream)

Jetstream

Solution

Add this method to app/Actions/Fortify/CreateNewUser.php file.



use Illuminate\Validation\Rules\Password;

// ...

protected function passwordRules()
{
    return ['required', 'string', Password::default()];
}


Enter fullscreen mode Exit fullscreen mode

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>


Enter fullscreen mode Exit fullscreen mode

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(),


Enter fullscreen mode Exit fullscreen mode

Under hood it uses passwordRules method from PasswordValidationRules trait. That method returns array with confirmed element:



return ['required', 'string', Password::default(), 'confirmed'];


Enter fullscreen mode Exit fullscreen mode

confirmed is a rule responsible for email confirmation, so we made our own passwordRules method which doesn't has confirmed rule.

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (3)

Collapse
 
neskodi profile image
Sergio Neskodi β€’

Also probably worth mentioning that you have to import Laravel\Fortify\Rules\Password; into your Action.

Collapse
 
neskodi profile image
Sergio Neskodi β€’

Thank you for taking time to put this out. This was useful.

Collapse
 
ostap profile image
Ostap Brehin β€’

Glad you liked it!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay