Commit realizando cambios en los roles de los usuarios

This commit is contained in:
Jaime Jimenez
2023-04-24 13:00:46 +02:00
parent 2d67588770
commit 8c4d77a598
6587 changed files with 365497 additions and 0 deletions

View 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;
}
}
}