laravel / jetstream

Tailwind scaffolding for the Laravel framework.
https://jetstream.laravel.com
MIT License
3.97k stars 822 forks source link

Remove password confirmation on Register #360

Closed ghost closed 4 years ago

ghost commented 4 years ago

Good day,

I am using Laravel 8 Jetstream with Livewire stack and pondering on how to remove the password confirmation on the register page can anyone assist?

I have removed the below:

<div class="mt-4">
     <x-jet-label value="Confirm Password" />
     <x-jet-input class="block mt-1 w-full" type="password" name="password_confirmation" required autocomplete="new-password" />
</div>

But the CreateNewUser.php only contains:

Validator::make($input, [
            'name' => ['required', 'string', 'max:255'],
            'username' => ['required', 'string', 'max:255', new UsernameRule, 'unique:users'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => $this->passwordRules(),
        ])->validate();

There is no confirmed will I need to to tweak something within the fortify config file

'features' => [
        Features::registration(),
        Features::resetPasswords(),
        Features::emailVerification(),
        Features::updateProfileInformation(),
        Features::updatePasswords(),
        Features::twoFactorAuthentication([
            'confirmPassword' => true,
        ]),
    ],
ibrunotome commented 4 years ago

Open the $this->passwordRules() and you will see ['required', 'string', new Password, 'confirmed'].

Just extract it to your validation, replace the $this->passwordRules() with it, and remove the confirmed rule.

ghost commented 4 years ago

Thank you @ibrunotome not sure how I missed that.

ghost commented 4 years ago

@ibrunotome is it required for me to extract it or can I not just alter the trait or is it best practice to use this instead ['required', 'string', new Password, 'confirmed']

ibrunotome commented 4 years ago

The trait is used in a lot of places, so you're right, update the trait will be better.

ghost commented 4 years ago

Thank you @ibrunotome