Modificación de validación al crear prospecto por correo
This commit is contained in:
@@ -2,13 +2,16 @@
|
||||
|
||||
namespace App\Actions\Fortify;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Prospecto;
|
||||
use Laravel\Jetstream\Jetstream;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Notifications\ResetPassword;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Laravel\Fortify\Contracts\CreatesNewUsers;
|
||||
use Laravel\Jetstream\Jetstream;
|
||||
|
||||
class CreateNewUser implements CreatesNewUsers
|
||||
{
|
||||
@@ -29,10 +32,11 @@ class CreateNewUser implements CreatesNewUsers
|
||||
'apellidoMaterno' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'telefono' => ['required', 'digits:10', 'unique:users,telefono'],
|
||||
'password' => $this->passwordRules(),
|
||||
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
|
||||
])->validate();
|
||||
|
||||
$passwordTemporal = Str::random(12);
|
||||
|
||||
$user = User::create([
|
||||
'name' => mb_strtoupper($input['name'], 'UTF-8'),
|
||||
'apellidoPaterno' => mb_strtoupper($input['apellidoPaterno'], 'UTF-8'),
|
||||
@@ -40,7 +44,7 @@ class CreateNewUser implements CreatesNewUsers
|
||||
'email' => $input['email'],
|
||||
'telefono' => $input['telefono'],
|
||||
'direccion' => "",
|
||||
'password' => Hash::make($input['password']),
|
||||
'password' => Hash::make($passwordTemporal),
|
||||
'status' => 1
|
||||
]);
|
||||
|
||||
@@ -58,6 +62,12 @@ class CreateNewUser implements CreatesNewUsers
|
||||
|
||||
$prospecto->prospectos()->sync([$user->id]);
|
||||
|
||||
$token = Password::createToken($user);
|
||||
$user->notify(new ResetPassword($token));
|
||||
|
||||
|
||||
session()->flash('registro_exitoso', 'Tu cuenta ha sido creada. Revisa tu correo electrónico para activar tu acceso.');
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +112,19 @@ Swal.fire({
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
|
||||
@if (session('registro_exitoso'))
|
||||
<script>
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Registro exitoso',
|
||||
text: '{{ session("registro_exitoso") }}',
|
||||
confirmButtonText: 'Entendido'
|
||||
}).then(() => {
|
||||
window.location.href = "{{ route('login') }}";
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user