mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'dev/usersperrol' into 'main'
creada funcion dentro del modelo de la tabla pivote group_user para tener el... See merge request jjimenez/safekat!17
This commit is contained in:
@ -3,8 +3,7 @@
|
|||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Usuarios\UserGroupModel;
|
use App\Models\Usuarios\GroupUserModel;
|
||||||
use App\Entities\Usuarios\UserGroupEntity;
|
|
||||||
|
|
||||||
class Test extends BaseController
|
class Test extends BaseController
|
||||||
{
|
{
|
||||||
@ -17,122 +16,8 @@ class Test extends BaseController
|
|||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
helper('general');
|
$model = new GroupUserModel();
|
||||||
|
var_dump($model->getUsersWithRol('115b5ad39b853084209caf6824224f6b'));
|
||||||
|
|
||||||
echo '<pre>';
|
|
||||||
var_dump(getMenuControl());
|
|
||||||
var_dump(json_decode(session()->get('rules')??'[]'));
|
|
||||||
|
|
||||||
echo '</pre>';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public function validateControllerAccess(){
|
|
||||||
$request = \Config\Services::request();
|
|
||||||
$uri = $uri = new \CodeIgniter\HTTP\URI('https://sk-jjo.imnavajas.es/envioslogistica/logistica');
|
|
||||||
$language = \Config\Services::language();
|
|
||||||
$language->setLocale(session()->lang);
|
|
||||||
|
|
||||||
$getWhiteList = $this->whiteListController();
|
|
||||||
|
|
||||||
foreach ($getWhiteList as $item){
|
|
||||||
if(strtolower($item) == $uri->getSegment(1)){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$getRules = json_decode(session()->get('rules')??'[]');
|
|
||||||
|
|
||||||
foreach ($this->whiteListMethod() as $item){
|
|
||||||
if(strtolower($item) == $uri->getSegment(2)){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($getRules as $key=>$value){
|
|
||||||
if($key=='Digitalizacion') {
|
|
||||||
echo 'Hola';
|
|
||||||
}
|
|
||||||
if(strtolower($key) == $uri->getSegment(1)){
|
|
||||||
if($uri->getTotalSegments() <= 1){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
foreach ($value as $item){
|
|
||||||
if(strtolower($item) == $uri->getSegment(2)){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
foreach($this->controllerFolderWhiteList() as $folder){
|
|
||||||
|
|
||||||
if(strtolower($folder) == $uri->getSegment(1)){
|
|
||||||
|
|
||||||
if(strtolower($key) == $uri->getSegment(2)){
|
|
||||||
if($uri->getTotalSegments() <= 2){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($value as $item){
|
|
||||||
if(strtolower($item) == $uri->getSegment(3)){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function whiteListController(){
|
|
||||||
return [
|
|
||||||
'',
|
|
||||||
'BaseController',
|
|
||||||
'Home',
|
|
||||||
'Login',
|
|
||||||
'Oauth',
|
|
||||||
'Language',
|
|
||||||
'Api',
|
|
||||||
'Cron',
|
|
||||||
'lang',
|
|
||||||
'Ajax',
|
|
||||||
'Integration',
|
|
||||||
'Migrate',
|
|
||||||
'Test',
|
|
||||||
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function whiteListMethod(){
|
|
||||||
return [
|
|
||||||
'initController',
|
|
||||||
'__construct',
|
|
||||||
'validateControllerAccess',
|
|
||||||
'whiteListController',
|
|
||||||
'whiteListMethod'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function controllerFolderWhiteList(){
|
|
||||||
return [
|
|
||||||
'Catalogo',
|
|
||||||
'Clientes',
|
|
||||||
'Configuracion',
|
|
||||||
'Digitalizacion',
|
|
||||||
'Facturacion',
|
|
||||||
'Informes',
|
|
||||||
'EnviosLogistica',
|
|
||||||
'Pedidos',
|
|
||||||
'Presupuestos',
|
|
||||||
'Produccion',
|
|
||||||
'Proveedores',
|
|
||||||
'Tarifas',
|
|
||||||
'Usuarios',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -10,4 +10,10 @@ class GroupUserModel extends BaseModel
|
|||||||
'token_user',
|
'token_user',
|
||||||
'token_group'
|
'token_group'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getUsersWithRol($token_group){
|
||||||
|
|
||||||
|
$result = $this->select('token_user')->where('token_group', $token_group)->countAllResults();
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user