@@ -168,4 +168,12 @@ class Cache extends BaseConfig
|
||||
'redis' => RedisHandler::class,
|
||||
'wincache' => WincacheHandler::class,
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (ENVIRONMENT === 'testing') {
|
||||
$this->storePath = WRITEPATH . 'cache/testing/';
|
||||
$this->file['storePath'] = WRITEPATH . 'cache/testing/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,13 +211,7 @@ class AuthController extends BaseController
|
||||
$this->logLoginAttempt($user['id'], $user['email'], $ip, $this->request->getUserAgent());
|
||||
|
||||
// Fetch roles
|
||||
$userRoleModel = new UserRoleModel();
|
||||
$rolesRows = $userRoleModel->select('roles.name')
|
||||
->join('roles', 'roles.id = user_roles.role_id')
|
||||
->where('user_roles.user_id', $user['id'])
|
||||
->get()
|
||||
->getResultArray();
|
||||
$roleNames = array_column($rolesRows, 'name');
|
||||
$roleNames = $this->getUserRoleNames((int) $user['id']);
|
||||
|
||||
// Build roles map (object with keys per example)
|
||||
$rolesMap = [];
|
||||
@@ -454,6 +448,18 @@ class AuthController extends BaseController
|
||||
$this->userModel->update($userId, ['failed_attempts' => 0, 'last_failed_at' => null]);
|
||||
}
|
||||
|
||||
protected function getUserRoleNames(int $userId): array
|
||||
{
|
||||
$userRoleModel = new UserRoleModel();
|
||||
$rolesRows = $userRoleModel->select('roles.name')
|
||||
->join('roles', 'roles.id = user_roles.role_id')
|
||||
->where('user_roles.user_id', $userId)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
return array_column($rolesRows, 'name');
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
// Get user ID and email from session
|
||||
|
||||
Reference in New Issue
Block a user