Modificación de validación al crear prospecto por correo
This commit is contained in:
@@ -2,13 +2,16 @@
|
|||||||
|
|
||||||
namespace App\Actions\Fortify;
|
namespace App\Actions\Fortify;
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use App\Models\Prospecto;
|
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\Hash;
|
||||||
|
use Illuminate\Support\Facades\Password;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Laravel\Fortify\Contracts\CreatesNewUsers;
|
use Laravel\Fortify\Contracts\CreatesNewUsers;
|
||||||
|
use Laravel\Jetstream\Jetstream;
|
||||||
|
|
||||||
class CreateNewUser implements CreatesNewUsers
|
class CreateNewUser implements CreatesNewUsers
|
||||||
{
|
{
|
||||||
@@ -29,10 +32,11 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
'apellidoMaterno' => ['required', 'string', 'max:255'],
|
'apellidoMaterno' => ['required', 'string', 'max:255'],
|
||||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||||
'telefono' => ['required', 'digits:10', 'unique:users,telefono'],
|
'telefono' => ['required', 'digits:10', 'unique:users,telefono'],
|
||||||
'password' => $this->passwordRules(),
|
|
||||||
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
|
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
|
||||||
])->validate();
|
])->validate();
|
||||||
|
|
||||||
|
$passwordTemporal = Str::random(12);
|
||||||
|
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'name' => mb_strtoupper($input['name'], 'UTF-8'),
|
'name' => mb_strtoupper($input['name'], 'UTF-8'),
|
||||||
'apellidoPaterno' => mb_strtoupper($input['apellidoPaterno'], 'UTF-8'),
|
'apellidoPaterno' => mb_strtoupper($input['apellidoPaterno'], 'UTF-8'),
|
||||||
@@ -40,7 +44,7 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
'email' => $input['email'],
|
'email' => $input['email'],
|
||||||
'telefono' => $input['telefono'],
|
'telefono' => $input['telefono'],
|
||||||
'direccion' => "",
|
'direccion' => "",
|
||||||
'password' => Hash::make($input['password']),
|
'password' => Hash::make($passwordTemporal),
|
||||||
'status' => 1
|
'status' => 1
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -58,6 +62,12 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
|
|
||||||
$prospecto->prospectos()->sync([$user->id]);
|
$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;
|
return $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,19 @@ Swal.fire({
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endif
|
@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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user