Arreglado el inscribir un nuevo usuario

This commit is contained in:
Jaime Jimenez
2023-07-15 12:09:27 +02:00
parent 4af11ec3e2
commit 2fca432213
7 changed files with 55 additions and 35 deletions

View File

@ -50,9 +50,12 @@ class Integration extends BaseController
if(!empty($user)){ if(!empty($user)){
foreach (keywordEmail()??[] as $item){ foreach (keywordEmail()??[] as $item){
$field = str_replace(['[','user_',']'],'',$item); $field = str_replace(['[','user_',']'],'',$item);
$body = str_replace('['.$item.']',$user[$field],$body); if(str_contains($body, $field)){
$body = str_replace('['.$item.']',$user->{$field},$body);
}
} }
} }
if($this->sendMail($subject,unescape($body),$email)){ if($this->sendMail($subject,unescape($body),$email)){
return $json ? json_encode(["return" => true]) : true; return $json ? json_encode(["return" => true]) : true;
}else{ }else{

View File

@ -365,7 +365,7 @@ class login extends BaseController
$rules = [ $rules = [
'first_name' => 'required', 'first_name' => 'required',
'last_name' => 'required', 'last_name' => 'required',
'email' => 'required|valid_email|is_unique[user.email]', 'email' => 'required|valid_email|is_unique[auth_user.email]',
'password' => 'required|min_length[8]' 'password' => 'required|min_length[8]'
]; ];
$rules_error = [ $rules_error = [
@ -385,9 +385,10 @@ class login extends BaseController
'min_length' => lang("App.login_rules_password_m") 'min_length' => lang("App.login_rules_password_m")
] ]
]; ];
if ($this->validate($rules,$rules_error)){ if ($this->validate($rules,$rules_error)){
if($listPost = $this->request->getPost()) { if($listPost = $this->request->getPost()) {
if($settings['captcha_register']??false){ if($settings['captcha_register']??false){
if($settings['captcha_gateway'] == 'recaptcha'){ if($settings['captcha_gateway'] == 'recaptcha'){
if(isset($listPost['g-recaptcha-response'])){ if(isset($listPost['g-recaptcha-response'])){
@ -426,8 +427,8 @@ class login extends BaseController
} }
$phpass = new PasswordHash(8, true); $phpass = new PasswordHash(8, true);
$userToken = md5(uniqid(rand(), true)); $userToken = md5(uniqid(rand(), true));
$this->user_model->save([ $this->user_model->skipValidation(true)->save([
'group' => $settings['default_role'], //'group' => $settings['default_role'],
'first_name' => $listPost['first_name'], 'first_name' => $listPost['first_name'],
'last_name' => $listPost['last_name'], 'last_name' => $listPost['last_name'],
'mobile' => '', 'mobile' => '',
@ -438,7 +439,12 @@ class login extends BaseController
'last_ip' => '::1', 'last_ip' => '::1',
'language' => $settings['default_language'], 'language' => $settings['default_language'],
'token' => $userToken, 'token' => $userToken,
'status' => true 'status' => 1,
'address' => '',
'city' => '',
'state' => '',
'country' => '',
'zip_code' => '',
]); ]);
//Get Data Template //Get Data Template
$templates = $this->template_model->findAll(); $templates = $this->template_model->findAll();
@ -450,6 +456,7 @@ class login extends BaseController
try { try {
$this->integration->send_email($listPost['email'],$template['subject'],$template['body'],$phpass->HashPassword(MD5($listPost['email']))); $this->integration->send_email($listPost['email'],$template['subject'],$template['body'],$phpass->HashPassword(MD5($listPost['email'])));
}catch (\Exception $e){ }catch (\Exception $e){
} }
} }
} }

View File

@ -11,8 +11,8 @@ class Maquina extends \CodeIgniter\Entity\Entity
"is_padre" => false, "is_padre" => false,
"tipo" => null, "tipo" => null,
"velocidad" => 0.0, "velocidad" => 0.0,
"ancho" => null, "ancho" => 100.0,
"alto" => null, "alto" => 100.0,
"ancho_impresion" => 0.0, "ancho_impresion" => 0.0,
"alto_impresion" => 0.0, "alto_impresion" => 0.0,
"alto_click" => 0.0, "alto_click" => 0.0,
@ -27,10 +27,10 @@ class Maquina extends \CodeIgniter\Entity\Entity
"precio_tinta_color" => 0.0, "precio_tinta_color" => 0.0,
"velocidad_corte" => 0.0, "velocidad_corte" => 0.0,
"precio_hora_corte" => 0.0, "precio_hora_corte" => 0.0,
"metrosxminuto" => null, "metrosxminuto" => 0.0,
"forzar_num_formas_horizontales_portada" => null, "forzar_num_formas_horizontales_portada" => null,
"forzar_num_formas_verticales_portada" => null, "forzar_num_formas_verticales_portada" => null,
"observaciones" => null, "observaciones" => "",
"is_deleted" => 0, "is_deleted" => 0,
"created_at" => null, "created_at" => null,
"updated_at" => null, "updated_at" => null,

View File

@ -7,15 +7,14 @@ class UserEntity extends \CodeIgniter\Entity\Entity
{ {
protected $attributes = [ protected $attributes = [
"id_user" => null, "id_user" => null,
"group" => null,
"first_name" => null, "first_name" => null,
"last_name" => null, "last_name" => null,
"date_birth" => null, "date_birth" => null,
"address" => null, "address" => "",
"city" => null, "city" => "",
"state" => null, "state" => "",
"country" => null, "country" => "",
"zip_code" => null, "zip_code" => "",
"mobile" => null, "mobile" => null,
"email" => null, "email" => null,
"password" => null, "password" => null,
@ -24,8 +23,8 @@ class UserEntity extends \CodeIgniter\Entity\Entity
"picture" => "/assets/img/default-user.png", "picture" => "/assets/img/default-user.png",
"language" => null, "language" => null,
"tfa" => false, "tfa" => false,
"tfa_secret" => null, "tfa_secret" => "",
"tfa_code" => null, "tfa_code" => "",
"blocked" => null, "blocked" => null,
"email_confirmed" => 0, "email_confirmed" => 0,
"token" => null, "token" => null,

View File

@ -199,7 +199,7 @@ class MaquinaModel extends \App\Models\GoBaseModel
], ],
"observaciones" => [ "observaciones" => [
"max_length" => "Maquinas.validation.observaciones.max_length", "max_length" => "Maquinas.validation.observaciones.max_length",
"required" => "Maquinas.validation.observaciones.required", //"required" => "Maquinas.validation.observaciones.required",
], ],
"orden_planning" => [ "orden_planning" => [
"integer" => "Maquinas.validation.orden_planning.integer", "integer" => "Maquinas.validation.orden_planning.integer",

View File

@ -8,7 +8,7 @@
<label for="nombre" class="form-label"> <label for="nombre" class="form-label">
<?=lang('Maquinas.nombre') ?>* <?=lang('Maquinas.nombre') ?>*
</label> </label>
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $maquina->nombre) ?>"> <input type="text" id="nombre" name="nombre" maxLength="255" class="form-control" value="<?=old('nombre', $maquina->nombre) ?>">
</div><!--//.col --> </div><!--//.col -->
</div><!--//.mb-3 --> </div><!--//.mb-3 -->
@ -17,7 +17,7 @@
<label for="min" class="form-label"> <label for="min" class="form-label">
<?=lang('Maquinas.min') ?>* <?=lang('Maquinas.min') ?>*
</label> </label>
<input type="number" id="min" name="min" required placeholder="1" maxLength="11" class="form-control" value="<?=old('min', $maquina->min) ?>"> <input type="number" id="min" name="min" placeholder="1" maxLength="11" class="form-control" value="<?=old('min', $maquina->min) ?>">
</div> </div>
</div><!--//.col --> </div><!--//.col -->
@ -26,7 +26,7 @@
<label for="max" class="form-label"> <label for="max" class="form-label">
<?=lang('Maquinas.max') ?>* <?=lang('Maquinas.max') ?>*
</label> </label>
<input type="number" id="max" name="max" required placeholder="1000000" maxLength="11" class="form-control" value="<?=old('max', $maquina->max) ?>"> <input type="number" id="max" name="max" placeholder="1000000" maxLength="11" class="form-control" value="<?=old('max', $maquina->max) ?>">
</div> </div>
</div><!--//.col --> </div><!--//.col -->
@ -35,7 +35,7 @@
<label for="velocidad" class="form-label"> <label for="velocidad" class="form-label">
<?=lang('Maquinas.velocidad') ?>* <?=lang('Maquinas.velocidad') ?>*
</label> </label>
<input type="number" id="velocidad" name="velocidad" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('velocidad', $maquina->velocidad) ?>"> <input type="number" id="velocidad" name="velocidad" placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('velocidad', $maquina->velocidad) ?>">
</div> </div>
</div><!--//.col --> </div><!--//.col -->
@ -44,7 +44,7 @@
<label for="tipo" class="form-label"> <label for="tipo" class="form-label">
<?=lang('Maquinas.tipo') ?>* <?=lang('Maquinas.tipo') ?>*
</label> </label>
<select id="tipo" name="tipo" required class="form-control select2bs" style="width: 100%;" > <select id="tipo" name="tipo" class="form-control select2bs" style="width: 100%;" >
<option value="" selected="selected"><?=lang('Basic.global.pleaseSelectOne') ?></option> <option value="" selected="selected"><?=lang('Basic.global.pleaseSelectOne') ?></option>
<option value="impresion"<?=$maquina->tipo == 'impresion' ? ' selected':'' ?>><?= lang('Maquinas.impresion') ?></option> <option value="impresion"<?=$maquina->tipo == 'impresion' ? ' selected':'' ?>><?= lang('Maquinas.impresion') ?></option>
<option value="manipulado"<?=$maquina->tipo == 'manipulado' ? ' selected':'' ?>><?= lang('Maquinas.manipulado') ?></option> <option value="manipulado"<?=$maquina->tipo == 'manipulado' ? ' selected':'' ?>><?= lang('Maquinas.manipulado') ?></option>
@ -63,7 +63,7 @@
<label for="ancho" class="form-label"> <label for="ancho" class="form-label">
<?=lang('Maquinas.ancho') ?>* <?=lang('Maquinas.ancho') ?>*
</label> </label>
<input type="number" id="ancho" name="ancho" maxLength="8" step="0.01" class="form-control" value="<?=old('ancho', $maquina->ancho) ?>"> <input type="number" id="ancho" name="ancho" placeholder="100.0" maxLength="8" step="0.01" class="form-control" value="<?=old('ancho', $maquina->ancho) ?>">
</div> </div>
</div><!--//.col --> </div><!--//.col -->
@ -72,7 +72,7 @@
<label for="alto" class="form-label"> <label for="alto" class="form-label">
<?=lang('Maquinas.alto') ?>* <?=lang('Maquinas.alto') ?>*
</label> </label>
<input type="number" id="alto" name="alto" maxLength="8" step="0.01" class="form-control" value="<?=old('alto', $maquina->alto) ?>"> <input type="number" id="alto" name="alto" placeholder="100.0" maxLength="8" step="0.01" class="form-control" value="<?=old('alto', $maquina->alto) ?>">
</div> </div>
</div><!--//.col --> </div><!--//.col -->
@ -81,7 +81,7 @@
<label for="anchoImpresion" class="form-label"> <label for="anchoImpresion" class="form-label">
<?=lang('Maquinas.anchoImpresion') ?>* <?=lang('Maquinas.anchoImpresion') ?>*
</label> </label>
<input type="number" id="anchoImpresion" name="ancho_impresion" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('ancho_impresion', $maquina->ancho_impresion) ?>"> <input type="number" id="anchoImpresion" name="ancho_impresion" placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('ancho_impresion', $maquina->ancho_impresion) ?>">
</div> </div>
</div><!--//.col --> </div><!--//.col -->
@ -90,7 +90,7 @@
<label for="altoImpresion" class="form-label"> <label for="altoImpresion" class="form-label">
<?=lang('Maquinas.altoImpresion') ?>* <?=lang('Maquinas.altoImpresion') ?>*
</label> </label>
<input type="number" id="altoImpresion" name="alto_impresion" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('alto_impresion', $maquina->alto_impresion) ?>"> <input type="number" id="altoImpresion" name="alto_impresion" placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('alto_impresion', $maquina->alto_impresion) ?>">
</div> </div>
</div><!--//.col --> </div><!--//.col -->
@ -99,7 +99,7 @@
<label for="altoClick" class="form-label"> <label for="altoClick" class="form-label">
<?=lang('Maquinas.altoClick') ?>* <?=lang('Maquinas.altoClick') ?>*
</label> </label>
<input type="number" id="altoClick" name="alto_click" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('alto_click', $maquina->alto_click) ?>"> <input type="number" id="altoClick" name="alto_click" placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('alto_click', $maquina->alto_click) ?>">
</div> </div>
</div><!--//.col --> </div><!--//.col -->
@ -114,7 +114,7 @@
<label for="duracionJornada" class="form-label" > <label for="duracionJornada" class="form-label" >
<?=lang('Maquinas.duracionJornada') ?>* <?=lang('Maquinas.duracionJornada') ?>*
</label> </label>
<input type="number" id="duracionJornada" name="duracion_jornada" required placeholder="8" maxLength="11" class="form-control" value="<?=old('duracion_jornada', $maquina->duracion_jornada) ?>"> <input type="number" id="duracionJornada" name="duracion_jornada" placeholder="8" maxLength="11" class="form-control" value="<?=old('duracion_jornada', $maquina->duracion_jornada) ?>">
</div> </div>
</div><!--//.col --> </div><!--//.col -->
@ -123,7 +123,7 @@
<label for="ordenPlanning" class="form-label"> <label for="ordenPlanning" class="form-label">
<?=lang('Maquinas.ordenPlanning') ?>* <?=lang('Maquinas.ordenPlanning') ?>*
</label> </label>
<input type="number" id="ordenPlanning" name="orden_planning" required placeholder="1" maxLength="11" class="form-control" value="<?=old('orden_planning', $maquina->orden_planning) ?>"> <input type="number" id="ordenPlanning" name="orden_planning" placeholder="1" maxLength="11" class="form-control" value="<?=old('orden_planning', $maquina->orden_planning) ?>">
</div> </div>
</div><!--//.col --> </div><!--//.col -->

View File

@ -43,13 +43,24 @@
<form id="sendForm" class="mb-3" action="<?=site_url("login/store")?>" method="POST"> <form id="sendForm" class="mb-3" action="<?=site_url("login/store")?>" method="POST">
<?= csrf_field() ?> <?= csrf_field() ?>
<div class="mb-3"> <div class="mb-3">
<label for="username" class="form-label">Username</label> <label for="first_name" class="form-label"><?= lang("App.login_first_name") ?></label>
<input <input
type="text" type="text"
class="form-control" class="form-control"
id="username" id="first_name"
name="username" name="first_name"
placeholder="Enter your username" placeholder=<?= lang("App.login_first_name_ph") ?>
autofocus
/>
</div>
<div class="mb-3">
<label for="last_name" class="form-label"><?= lang("App.login_last_name") ?></label>
<input
type="text"
class="form-control"
id="last_name"
name="last_name"
placeholder=<?= lang("App.login_last_name_ph") ?>
autofocus autofocus
/> />
</div> </div>