Actualizando entre versiones de CI4 (upgrade

This commit is contained in:
imnavajas
2024-05-01 20:33:29 +02:00
parent 3a4bd1022c
commit 0c4888f9b3
16 changed files with 78 additions and 64 deletions

5
.idea/php.xml generated
View File

@ -63,6 +63,11 @@
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PhpUnit">
<phpunit_settings>
<PhpUnitSettings custom_loader_path="$PROJECT_DIR$/ci4/vendor/autoload.php" />
</phpunit_settings>
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>

View File

@ -13,19 +13,19 @@ declare(strict_types=1);
namespace Config;
use App\Models\UserModel;
use CodeIgniter\Shield\Authentication\Passwords\ValidationRules;
use CodeIgniter\Shield\Config\Auth as ShieldAuth;
use CodeIgniter\Shield\Authentication\Actions\ActionInterface;
use CodeIgniter\Shield\Authentication\AuthenticatorInterface;
use CodeIgniter\Shield\Authentication\Authenticators\AccessTokens;
use CodeIgniter\Shield\Authentication\Authenticators\HmacSha256;
use CodeIgniter\Shield\Authentication\Authenticators\JWT;
use CodeIgniter\Shield\Authentication\Authenticators\Session;
use CodeIgniter\Shield\Authentication\Passwords\CompositionValidator;
use CodeIgniter\Shield\Authentication\Passwords\DictionaryValidator;
use CodeIgniter\Shield\Authentication\Passwords\NothingPersonalValidator;
use CodeIgniter\Shield\Authentication\Passwords\PwnedValidator;
use CodeIgniter\Shield\Authentication\Passwords\ValidatorInterface;
use CodeIgniter\Shield\Models\UserModel;
class Auth extends ShieldAuth
{
@ -269,7 +269,7 @@ class Auth extends ShieldAuth
public array $passwordValidators = [
CompositionValidator::class,
NothingPersonalValidator::class,
DictionaryValidator::class,
DictionaryValidator::class
// PwnedValidator::class,
];

View File

@ -13,7 +13,12 @@ use CodeIgniter\Config\AutoloadConfig;
* can find the files as needed.
*
* NOTE: If you use an identical key in $psr4 or $classmap, then
* the values in this file will overwrite the framework's values.
* the values in this file will overwrite the framework's values.
*
* NOTE: This class is required prior to Autoloader instantiation,
* and does not extend BaseConfig.
*
* @immutable
*/
class Autoload extends AutoloadConfig
{
@ -31,14 +36,12 @@ class Autoload extends AutoloadConfig
* else you will need to modify all of those classes for this to work.
*
* Prototype:
*```
* $psr4 = [
* 'CodeIgniter' => SYSTEMPATH,
* 'App' => APPPATH
* 'App' => APPPATH
* ];
*```
*
* @var array<string, string>
* @var array<string, list<string>|string>
*/
public $psr4 = [
APP_NAMESPACE => APPPATH, // For custom app namespace
@ -57,11 +60,9 @@ class Autoload extends AutoloadConfig
* were being autoloaded through a namespace.
*
* Prototype:
*```
* $classmap = [
* 'MyClass' => '/path/to/class/file.php'
* ];
*```
*
* @var array<string, string>
*/
@ -76,13 +77,11 @@ class Autoload extends AutoloadConfig
* or for loading functions.
*
* Prototype:
* ```
* $files = [
* '/path/to/my/file.php',
* ];
* ```
* $files = [
* '/path/to/my/file.php',
* ];
*
* @var array<int, string>
* @var list<string>
*/
public $files = [];

View File

@ -7,8 +7,10 @@
| In development, we want to show as many errors as possible to help
| make sure they don't make it to production. And save us hours of
| painful debugging.
|
| If you set 'display_errors' to '1', CI4's detailed error report will show.
*/
error_reporting(-1);
error_reporting(E_ALL);
ini_set('display_errors', '1');
/*

View File

@ -6,6 +6,8 @@
|--------------------------------------------------------------------------
| Don't show ANY in production environments. Instead, let the system catch
| it and display a generic error message.
|
| If you set 'display_errors' to '1', CI4's detailed error report will show.
*/
ini_set('display_errors', '0');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);

View File

@ -1,5 +1,11 @@
<?php
/*
* The environment testing is reserved for PHPUnit testing. It has special
* conditions built into the framework at various places to assist with that.
* You cant use it for your development.
*/
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
@ -8,7 +14,7 @@
| make sure they don't make it to production. And save us hours of
| painful debugging.
*/
error_reporting(-1);
error_reporting(E_ALL);
ini_set('display_errors', '1');
/*

View File

@ -2,6 +2,8 @@
namespace Config;
use CodeIgniter\Shield\Authentication\Passwords\ValidationRules;
use CodeIgniter\Validation\CreditCardRules;
use CodeIgniter\Validation\FileRules;
use CodeIgniter\Validation\FormatRules;
@ -19,12 +21,12 @@ class Validation
*
* @var string[]
*/
public $ruleSets = [
public array $ruleSets = [
Rules::class,
FormatRules::class,
FileRules::class,
CreditCardRules::class,
\App\Validation\ApiAuthRules::class,
ValidationRules::class,
];
/**
@ -33,7 +35,7 @@ class Validation
*
* @var array<string, string>
*/
public $templates = [
public array $templates = [
'list' => 'CodeIgniter\Validation\Views\list',
'single' => 'CodeIgniter\Validation\Views\single',
'bootstrap_style' => 'themes/_commonPartialsBs/_form_validation_errors',
@ -43,4 +45,38 @@ class Validation
//--------------------------------------------------------------------
// Rules
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Rules For Login
//--------------------------------------------------------------------
/*public $login = [
// 'username' => [
// 'label' => 'Auth.username',
// 'rules' => [
// 'required',
// 'max_length[30]',
// 'min_length[3]',
// 'regex_match[/\A[a-zA-Z0-9\.]+\z/]',
// ],
// ],
'email' => [
'label' => 'Auth.email',
'rules' => [
'required',
'max_length[254]',
'valid_email'
],
],
'password' => [
'label' => 'Auth.password',
'rules' => [
'required',
'max_byte[72]',
],
'errors' => [
'max_byte' => 'Auth.errorPasswordTooLongBytes',
]
],
];*/
}

View File

@ -1,36 +0,0 @@
<?php
namespace App\Validation;
use App\Libraries\PasswordHash;
use App\Models\SettingsModel;
use App\Models\Usuarios\UserModel;
use Exception;
class ApiAuthRules
{
public function validateAuthPassword(string $str, string $fields, array $data): bool
{
try {
$user_model = new UserModel();
$obj = $user_model->where('email',$data['email'])->first();
$phpass = new PasswordHash(8, true);
return $phpass->CheckPassword($data['password']??'', $obj['password']);
} catch (Exception $e) {
return false;
}
}
public function validateAuthPermission(string $str, string $fields, array $data): bool
{
try {
$user_model = new UserModel();
$settings_model = new SettingsModel();
$settings = $settings_model->first()??[];
$obj = $user_model->where('email',$data['email'])->first();
return $settings['group_api'] == $obj['group'];
} catch (Exception $e) {
return false;
}
}
}

View File

@ -269,7 +269,7 @@ if (!empty($token) && $tfa == false) {
<div class="dropdown-divider"></div>
</li>
<li>
<a class="dropdown-item" href="<?= site_url("login/logout") ?>">
<a class="dropdown-item" href="<?= site_url("logout") ?>">
<i class="ti ti-logout me-2 ti-sm"></i>
<span class="align-middle"><?= lang("App.menu_logout") ?></span>
</a>

View File

@ -502,7 +502,7 @@ if (!empty($token) && $tfa == false) {
<div class="dropdown-divider"></div>
</li>
<li>
<a class="dropdown-item" href="<?= site_url("login/logout") ?>">
<a class="dropdown-item" href="<?= site_url("logout") ?>">
<i class="ti ti-logout me-2 ti-sm"></i>
<span class="align-middle"><?= lang("App.menu_logout") ?></span>
</a>

View File

@ -267,7 +267,7 @@ if (!empty($token) && $tfa == false) {
<div class="dropdown-divider"></div>
</li>
<li>
<a class="dropdown-item" href="<?= site_url("login/logout") ?>">
<a class="dropdown-item" href="<?= site_url("logout") ?>">
<i class="ti ti-logout me-2 ti-sm"></i>
<span class="align-middle"><?= lang("App.menu_logout") ?></span>
</a>

View File

@ -204,7 +204,7 @@ if (!empty($token) && $tfa == false) {
<div class="dropdown-divider"></div>
</li>
<li>
<a class="dropdown-item" href="<?= site_url("login/logout") ?>">
<a class="dropdown-item" href="<?= site_url("logout") ?>">
<i class="ti ti-logout me-2 ti-sm"></i>
<span class="align-middle"><?= lang("App.menu_logout") ?></span>
</a>

View File

@ -272,7 +272,7 @@ if (!empty($token) && $tfa == false) {
<div class="dropdown-divider"></div>
</li>
<li>
<a class="dropdown-item" href="<?= site_url("login/logout") ?>">
<a class="dropdown-item" href="<?= site_url("logout") ?>">
<i class="ti ti-logout me-2 ti-sm"></i>
<span class="align-middle"><?= lang("App.menu_logout") ?></span>
</a>

View File

@ -174,7 +174,7 @@ if (!empty($token) && $tfa == false) {
<span class="ml-2"><?= lang("App.menu_activity") ?></span>
</a>
--->
<a href="<?= site_url('login/logout'); ?>" class="dropdown-item">
<a href="<?= site_url('logout'); ?>" class="dropdown-item">
<i class="fas fa-sign-out-alt"></i>
<span class="ml-2"><?= lang("App.menu_logout") ?></span>
</a>

View File

@ -273,7 +273,7 @@ if (!empty($token) && $tfa == false) {
<div class="dropdown-divider"></div>
</li>
<li>
<a class="dropdown-item" href="<?= site_url("login/logout") ?>">
<a class="dropdown-item" href="<?= site_url("logout") ?>">
<i class="ti ti-logout me-2 ti-sm"></i>
<span class="align-middle"><?= lang("App.menu_logout") ?></span>
</a>