mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Commit realizando cambios en los roles de los usuarios
This commit is contained in:
36
ci4/app/Validation/ApiAuthRules.php
Normal file
36
ci4/app/Validation/ApiAuthRules.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Validation;
|
||||
|
||||
use App\Libraries\PasswordHash;
|
||||
use App\Models\SettingsModel;
|
||||
use App\Models\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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user