mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'dev/anadir_ficheros_presu'
Main See merge request jjimenez/safekat!262
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);
|
||||
@ -296,6 +304,22 @@ class Users extends \App\Controllers\GoBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
public function getMenuComerciales(){
|
||||
if ($this->request->isAJAX()) {
|
||||
$comerciales = $this->model->getComerciales();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $comerciales,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getPaisListItems() {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Pais.pais'))])];
|
||||
|
||||
Reference in New Issue
Block a user