mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'bug/new_user' into 'main'
ya se pueden añadir usuarios See merge request jjimenez/safekat!258
This commit is contained in:
@ -67,7 +67,7 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
|
||||
$currentGroups = $postData['group']??[];
|
||||
unset($postData['group']);
|
||||
|
||||
$postData['username'] = strstr($postData['email'], '@', true);
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
$noException = true;
|
||||
@ -75,20 +75,28 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
$users = auth()->getProvider();
|
||||
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
|
||||
$user = new User([
|
||||
'username' => strstr($sanitizedData['email'], '@', true),
|
||||
'username' => $sanitizedData['username'],
|
||||
'first_name' => $sanitizedData['first_name'],
|
||||
'last_name' => $sanitizedData['last_name'],
|
||||
'email' => $sanitizedData['email'],
|
||||
'password' => 'Safekat2024',
|
||||
'status' => $sanitizedData['status']??0,
|
||||
'active' => $sanitizedData['active']??0,
|
||||
]);
|
||||
$users->save($user);
|
||||
$successfulResult = true; // Hacked
|
||||
$successfulResult = true; // Hacked
|
||||
} catch (\Exception $e) {
|
||||
$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:
|
||||
$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) :
|
||||
|
||||
$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){
|
||||
$group_user_data = [
|
||||
'user_id' => $user->id,
|
||||
'user_id' => $id,
|
||||
'group' => $group
|
||||
];
|
||||
$this->group_user_model->insert($group_user_data);
|
||||
|
||||
@ -19,11 +19,11 @@ class UserModel extends ShieldUserModel
|
||||
];
|
||||
}
|
||||
|
||||
/*protected $validationRules = [
|
||||
"email" => [
|
||||
"label" => "RolesPermisos.email",
|
||||
"rules" => "required|max_length[150]",
|
||||
protected $validationRules = [
|
||||
"username" => [
|
||||
"label" => "correo duplicado",
|
||||
"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