mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
36 lines
1.0 KiB
PHP
36 lines
1.0 KiB
PHP
<?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;
|
|
}
|
|
}
|
|
} |