mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Arreglando profile y pequeños bugs
This commit is contained in:
2
.idea/php.xml
generated
2
.idea/php.xml
generated
@ -57,7 +57,7 @@
|
||||
<path value="$PROJECT_DIR$/ci4/vendor/codeigniter4/framework" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.1">
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.2">
|
||||
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||
</component>
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
|
||||
4
.idea/safekat.iml
generated
4
.idea/safekat.iml
generated
@ -1,9 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/ci4/app/ThirdParty/DatatablesEditor/" isTestSource="false" packagePrefix="DataTables\" />
|
||||
</content>
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
|
||||
@ -193,6 +193,7 @@ class Group extends \App\Controllers\GoBaseController
|
||||
// IMN hacer las configuraciones hard coded
|
||||
helper('rbac');
|
||||
generate_php_roles_constant();
|
||||
generate_php_permissions_constant();
|
||||
generate_php_permissions_matrix_constant();
|
||||
|
||||
$id = $groupEntity->id ?? $id;
|
||||
|
||||
@ -62,20 +62,14 @@ class Paises extends \App\Controllers\BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
@ -113,9 +107,7 @@ class Paises extends \App\Controllers\BaseResourceController
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['paisEntity'] = isset($sanitizedData) ? new PaisEntity($sanitizedData) : new PaisEntity();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createPais');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Paises.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
|
||||
@ -2,24 +2,20 @@
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Libraries\PasswordHash;
|
||||
use App\Models\CountriesModel;
|
||||
use App\Models\UserGroupModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
|
||||
use App\Models\UserModel;
|
||||
|
||||
class Profile extends BaseController
|
||||
{
|
||||
private $user_model;
|
||||
private $countries_model;
|
||||
private $id_user;
|
||||
private $token_user;
|
||||
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->user_model = new UserModel();
|
||||
$this->countries_model = new CountriesModel();
|
||||
$this->id_user = session()->get('id_user');
|
||||
$this->token_user = session()->get('token');
|
||||
$this->id_user = auth()->user()->id;
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
@ -55,46 +51,8 @@ class Profile extends BaseController
|
||||
|
||||
$session = session();
|
||||
|
||||
$data['obj'] = $this->user_model->where('id_user', $this->id_user)->first();
|
||||
$data['obj'] = $this->user_model->where('id', $this->id_user)->first();
|
||||
|
||||
if (!empty($data['obj']->date_birth)) {
|
||||
$data['obj']->date_birth = dateFormatWeb($data['obj']->date_birth);
|
||||
}
|
||||
$data['country'] = $this->countries_model->select('code,name')->where('data_lang', session()->get('lang') ?? 'en')->findAll();
|
||||
|
||||
$file = $this->request->getFile('file');
|
||||
if (!empty($file)) {
|
||||
$integration = new Integration();
|
||||
$allow = ['jpeg', 'jpg', 'gif', 'bmp', 'png'];
|
||||
$path = 'assets/img/';
|
||||
$pathRet = '/' . $integration->saveStorage($file, $path, $allow);
|
||||
if (!empty($pathRet)) {
|
||||
$this->user_model->save([
|
||||
'id_user' => $this->id_user,
|
||||
'picture' => $pathRet
|
||||
]);
|
||||
$data['obj']['picture'] = $pathRet;
|
||||
$session->set('picture', $pathRet);
|
||||
}
|
||||
} else {
|
||||
if (!empty($this->request->getPost())) {
|
||||
$post = $this->request->getPost();
|
||||
$image = '';
|
||||
foreach ($post as $key => $value) {
|
||||
if (strpos($key, 'image') !== false) {
|
||||
$image = $value;
|
||||
}
|
||||
}
|
||||
if (!empty($image)) {
|
||||
$this->user_model->save([
|
||||
'id_user' => $this->id_user,
|
||||
'picture' => $image
|
||||
]);
|
||||
$data['obj']['picture'] = $image;
|
||||
$session->set('picture', $image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo view(getenv('theme.path') . 'form/profile/index', $data);
|
||||
|
||||
@ -103,11 +61,9 @@ class Profile extends BaseController
|
||||
public function store()
|
||||
{
|
||||
|
||||
|
||||
$session = session();
|
||||
helper('form');
|
||||
|
||||
|
||||
$rules = [
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
@ -122,17 +78,10 @@ class Profile extends BaseController
|
||||
if ($this->validate($rules ?? [], $rules_error ?? [])) {
|
||||
if (!empty($this->id_user)) {
|
||||
$this->user_model->save([
|
||||
'id_user' => $this->id_user,
|
||||
'id' => $this->id_user,
|
||||
'first_name' => $this->request->getPost('first_name'),
|
||||
'last_name' => $this->request->getPost('last_name'),
|
||||
'address' => $this->request->getPost('address'),
|
||||
'city' => $this->request->getPost('city'),
|
||||
'state' => $this->request->getPost('state'),
|
||||
'country' => $this->request->getPost('country'),
|
||||
'mobile' => $this->request->getPost('mobile'),
|
||||
'language' => $this->request->getPost('language')
|
||||
'last_name' => $this->request->getPost('last_name')
|
||||
]);
|
||||
$session->set('lang', $this->request->getPost('language') ?? 'en');
|
||||
$session->setFlashdata('sweet', ['success', lang("App.global_alert_save_success")]);
|
||||
} else {
|
||||
$session->setFlashdata('sweet', ['error', lang("App.global_alert_save_error")]);
|
||||
@ -143,7 +92,6 @@ class Profile extends BaseController
|
||||
return $this->index();
|
||||
}
|
||||
|
||||
|
||||
return redirect()->to('/profile');
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,52 +5,9 @@
|
||||
<!--Content Body-->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<ul class="nav nav-pills flex-column flex-md-row mb-4">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="javascript:void(0);"
|
||||
><i class="ti-xs ti ti-users me-1"></i> Account</a
|
||||
>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="pages-account-settings-security.html"
|
||||
><i class="ti-xs ti ti-lock me-1"></i> Security</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="card mb-4">
|
||||
<h5 class="card-header">Profile Details</h5>
|
||||
<h5 class="card-header">Perfil de Usuario</h5>
|
||||
<!-- Account -->
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-start align-items-sm-center gap-4">
|
||||
<img
|
||||
src="<?= $obj->picture ?? '' ?>"
|
||||
alt="user-avatar"
|
||||
class="d-block w-px-100 h-px-100 rounded"
|
||||
id="uploadedAvatar"
|
||||
/>
|
||||
<div class="button-wrapper">
|
||||
<label for="upload" class="btn btn-primary me-2 mb-3" tabindex="0">
|
||||
<span class="d-none d-sm-block"><?= lang("App.profile_change_photo") ?></span>
|
||||
<i class="ti ti-upload d-block d-sm-none"></i>
|
||||
<input
|
||||
type="file"
|
||||
id="upload"
|
||||
class="account-file-input"
|
||||
hidden
|
||||
accept="image/png, image/jpeg"
|
||||
/>
|
||||
</label>
|
||||
<button type="button" class="btn btn-label-secondary account-image-reset mb-3">
|
||||
<i class="ti ti-refresh-dot d-block d-sm-none"></i>
|
||||
<span class="d-none d-sm-block">Reset</span>
|
||||
</button>
|
||||
|
||||
<div class="text-muted">Allowed JPG, GIF or PNG. Max size of 800K</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="my-0"/>
|
||||
<div class="card-body">
|
||||
<form id="formAccountSettings" method="POST" action="<?= site_url("profile/store") ?>">
|
||||
<?= csrf_field() ?>
|
||||
@ -88,71 +45,6 @@
|
||||
value="<?= (isset($obj)) ? $obj->email : set_value('email'); ?>"
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3 col-md-6">
|
||||
<label class="form-label" for="mobile"><?= lang("App.profile_mobile") ?></label>
|
||||
<div class="input-group input-group-merge">
|
||||
<input
|
||||
type="text"
|
||||
id="mobile"
|
||||
name="mobile"
|
||||
class="form-control"
|
||||
placeholder="<?= lang("App.profile_mobile_ph") ?>"
|
||||
value="<?= (isset($obj)) ? $obj->mobile : set_value('mobile'); ?>"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 col-md-6">
|
||||
<label for="address" class="form-label"><?= lang("App.profile_address") ?></label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="address"
|
||||
name="address"
|
||||
placeholder="<?= lang("App.profile_address_ph") ?>"
|
||||
value="<?= (isset($obj)) ? $obj->address : set_value('address'); ?>"
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3 col-md-6">
|
||||
<label for="state" class="form-label"><?= lang("App.profile_state") ?></label>
|
||||
<input
|
||||
class="form-control"
|
||||
type="text"
|
||||
id="state"
|
||||
name="state"
|
||||
placeholder="<?= lang("App.profile_state_ph") ?>"
|
||||
value="<?= (isset($obj)) ? $obj->state : set_value('state'); ?>"
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3 col-md-6">
|
||||
<label for="city" class="form-label"><?= lang("App.profile_city") ?></label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="city"
|
||||
name="city"
|
||||
placeholder="<?= lang("App.profile_city_ph") ?>"
|
||||
value="<?= (isset($obj)) ? $obj->city : set_value('city'); ?>"
|
||||
/>
|
||||
</div>
|
||||
<div class="mb-3 col-md-6">
|
||||
<label class="form-label" for="country"><?= lang("App.profile_country") ?></label>
|
||||
<?php $id_select = (isset($obj)) ? $obj->country ?? [] : set_value('country'); ?>
|
||||
<select name="country" id="country" class="select2 form-select">
|
||||
<option value=""><?= lang("App.global_select") ?></option>
|
||||
<?php foreach ($country ?? [] as $item) : ?>
|
||||
<option value="<?= $item['code'] ?? '' ?>" <?= $id_select == $item['code'] ? 'selected' : '' ?>><?= $item['name'] ?? '' ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3 col-md-6">
|
||||
<label for="language" class="form-label"><?= lang("App.profile_language") ?></label>
|
||||
<?php $id_select = (isset($obj)) ? $obj->language ?? [] : set_value('language'); ?>
|
||||
<select name="language" id="language" class="select2 form-select">
|
||||
<option value=""><?= lang("App.global_select") ?></option>
|
||||
<option value="en" <?= $id_select == "en" ? 'selected' : '' ?>><?= lang("App.lang_en") ?></option>
|
||||
<option value="es" <?= $id_select == "es" ? 'selected' : '' ?>><?= lang("App.lang_es") ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<button type="submit" class="btn btn-primary me-2"><?= $btn_submit['title'] ?? '' ?></button>
|
||||
@ -192,86 +84,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php $settings = session()->get('settings'); ?>
|
||||
|
||||
<?php if ($settings['two_factor_auth']) : ?>
|
||||
<form name="form_otp" class="form" action="<?= site_url("profile/store") ?>" method="post" id="sendFormTFA">
|
||||
<?= csrf_field() ?>
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row mx-0" style="width: 100%;">
|
||||
<div class="col-sm-6 p-md-0">
|
||||
<h4 class="card-title"><?= lang("App.profile_subtitle_tfa") ?></h4>
|
||||
</div>
|
||||
<div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
|
||||
<div class="custom-control custom-switch ml-2">
|
||||
<input type="checkbox" id="tfa" name="tfa" class="custom-control-input"
|
||||
onchange="tfaView()" <?= $obj['tfa'] ?? false ? 'checked' : '' ?>>
|
||||
<label for="tfa"
|
||||
class="custom-control-label"><?= lang("App.profile_tfa_msg") ?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="otp" style="display: <?= $obj['tfa'] ?? false ? 'block' : 'none' ?>">
|
||||
<?php
|
||||
$tfa = new \App\Libraries\Authenticator();
|
||||
$name = $obj['first_name'] ?? '';
|
||||
if ($obj['tfa'] && !empty($obj['tfa_secret'])) {
|
||||
$tfa_secret = $obj['tfa_secret'] ?? '';
|
||||
$qrcode = $tfa->GetQR("{$settings['title']} ({$name})", $tfa_secret);
|
||||
} else {
|
||||
$tfa_secret = $tfa->createSecret();
|
||||
$qrcode = $tfa->GetQR("{$settings['title']} ({$name})", $tfa_secret);
|
||||
}
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<p><b><?= lang("App.profile_qrcode") ?></b></p>
|
||||
<img src="<?php echo $qrcode; ?>" class="img-responsive">
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<p><b><?= lang("App.profile_backup_code") ?></b></p>
|
||||
<?php
|
||||
$codes = "";
|
||||
if (!empty($obj['tfa_code'] ?? '')) {
|
||||
$codes = explode(',', $obj['tfa_code'] ?? '');
|
||||
foreach ($codes as $item) {
|
||||
echo '<span class="badge badge-primary mr-2 mb-1">' . $item . '</span>';
|
||||
}
|
||||
} else {
|
||||
$codes = array();
|
||||
for ($i = 1; $i <= 8; $i++) {
|
||||
$code = random_string('numeric', 6);
|
||||
$codes[] = $code;
|
||||
echo '<span class="badge badge-primary mr-2 mb-1">' . $code . '</span>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<p class="mt-2"><b><?= lang("App.profile_tfa_secret") ?></b><br><b
|
||||
class="text-primary"><?= $tfa_secret ?></b></p>
|
||||
<input type="hidden" id="tfa_secret" name="tfa_secret"
|
||||
value="<?= $tfa_secret ?>">
|
||||
<input type="hidden" id="tfa_code" name="tfa_code"
|
||||
value="<?= implode(',', $codes) ?>">
|
||||
<button type="button" class="btn btn-primary btn-block mt-2"
|
||||
onclick="download('<?= lang("App.profile_qrcode") ?>\n<?= implode(",", $codes) ?>\n<?= lang("App.profile_tfa_secret") ?>\n<?= $tfa_secret ?>','backup_codes.txt')">
|
||||
<i class="fas fa-download mr-1"></i> <?= lang("App.profile_tfa_download") ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -280,28 +94,14 @@
|
||||
|
||||
|
||||
<?= $this->section('additionalInlineJs') ?>
|
||||
"use strict";
|
||||
$(document).ready(function () {
|
||||
$('#first_name').focus();
|
||||
});
|
||||
$('.file-upload').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
$('#file').trigger('click');
|
||||
});
|
||||
"use strict";
|
||||
$(document).ready(function () {
|
||||
$('#first_name').focus();
|
||||
});
|
||||
$('.file-upload').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
$('#file').trigger('click');
|
||||
});
|
||||
|
||||
<?php if ($settings['two_factor_auth']) : ?>
|
||||
function download(text, filename) {
|
||||
let blob = new Blob([text], {type: "text/plain;charset=utf-8"});
|
||||
let url = window.URL.createObjectURL(blob);
|
||||
let a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
}
|
||||
|
||||
function tfaView() {
|
||||
document.getElementById("sendFormTFA").submit();
|
||||
}
|
||||
<?php endif; ?>
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
@ -49,28 +49,22 @@
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!---
|
||||
<?php
|
||||
/**
|
||||
* JJO
|
||||
*/
|
||||
|
||||
<li class="menu-header small text-uppercase">
|
||||
<span class="menu-header-text">Test JJO</span>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
<a href="<?= route_to('nuevoPresupuestoCliente') ?>" class="menu-link">
|
||||
<i class="menu-icon tf-icons ti ti-settings"></i>
|
||||
<div data-i18n="Test">Test</div>
|
||||
</a>
|
||||
</li>
|
||||
--->
|
||||
|
||||
* JJO
|
||||
*/
|
||||
if (auth()->user()->inGroup('beta')) {
|
||||
?>
|
||||
<li class="menu-header small text-uppercase">
|
||||
<span class="menu-header-text">Test JJO</span>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
<a href="<?= route_to('nuevoPresupuestoCliente') ?>" class="menu-link">
|
||||
<i class="menu-icon tf-icons ti ti-settings"></i>
|
||||
Test
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
Reference in New Issue
Block a user