mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
ya se pueden añadir usuarios
This commit is contained in:
@ -67,7 +67,7 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
|
|
||||||
$currentGroups = $postData['group']??[];
|
$currentGroups = $postData['group']??[];
|
||||||
unset($postData['group']);
|
unset($postData['group']);
|
||||||
|
$postData['username'] = strstr($postData['email'], '@', true);
|
||||||
$sanitizedData = $this->sanitized($postData, true);
|
$sanitizedData = $this->sanitized($postData, true);
|
||||||
|
|
||||||
$noException = true;
|
$noException = true;
|
||||||
@ -75,20 +75,28 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
$users = auth()->getProvider();
|
$users = auth()->getProvider();
|
||||||
|
|
||||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||||
|
if ($this->canValidate()) :
|
||||||
if ($this->canValidate()) :
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$user = new User([
|
$user = new User([
|
||||||
'username' => strstr($sanitizedData['email'], '@', true),
|
'username' => $sanitizedData['username'],
|
||||||
|
'first_name' => $sanitizedData['first_name'],
|
||||||
|
'last_name' => $sanitizedData['last_name'],
|
||||||
'email' => $sanitizedData['email'],
|
'email' => $sanitizedData['email'],
|
||||||
'password' => 'Safekat2024',
|
'password' => 'Safekat2024',
|
||||||
|
'status' => $sanitizedData['status']??0,
|
||||||
|
'active' => $sanitizedData['active']??0,
|
||||||
]);
|
]);
|
||||||
$users->save($user);
|
$users->save($user);
|
||||||
$successfulResult = true; // Hacked
|
$successfulResult = true; // Hacked
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$noException = false;
|
$noException = false;
|
||||||
$this->dealWithException($e);
|
//$this->dealWithException($e);
|
||||||
|
if (strpos($e->getMessage(), 'correo duplicado') !== false) {
|
||||||
|
$this->viewData['errorMessage'] = "El correo electrónico ya está registrado en el sistema";
|
||||||
|
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Users.user'))]);
|
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Users.user'))]);
|
||||||
@ -100,10 +108,10 @@ class Users extends \App\Controllers\GoBaseController {
|
|||||||
if ($noException && $successfulResult) :
|
if ($noException && $successfulResult) :
|
||||||
|
|
||||||
$id = $users->getInsertID();
|
$id = $users->getInsertID();
|
||||||
$this->group_user_model->where('user_id', $user->id)->delete();
|
$this->group_user_model->where('user_id', $id)->delete();
|
||||||
foreach($currentGroups as $group){
|
foreach($currentGroups as $group){
|
||||||
$group_user_data = [
|
$group_user_data = [
|
||||||
'user_id' => $user->id,
|
'user_id' => $id,
|
||||||
'group' => $group
|
'group' => $group
|
||||||
];
|
];
|
||||||
$this->group_user_model->insert($group_user_data);
|
$this->group_user_model->insert($group_user_data);
|
||||||
|
|||||||
@ -19,11 +19,11 @@ class UserModel extends ShieldUserModel
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*protected $validationRules = [
|
protected $validationRules = [
|
||||||
"email" => [
|
"username" => [
|
||||||
"label" => "RolesPermisos.email",
|
"label" => "correo duplicado",
|
||||||
"rules" => "required|max_length[150]",
|
"rules" => "is_unique[users.username]",
|
||||||
]
|
]
|
||||||
|
|
||||||
];*/
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
6630
xdebug.log
6630
xdebug.log
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user