mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-09-15 23:07:45 -04:00
fix(sales): gate per-record endpoints behind reports_sales grant (REDACTED) Cashiers holding only the base `sales` grant could reach per-sale endpoints (getRow, getEdit, postSave, getReceipt, getInvoice, getSendPdf, getSendReceipt) that require `reports_sales`. getManage() enforced this at the list level, but individual endpoints did not re-check. Regression tests added. Auth: - Introduce `IsLoggedIn` filter to centralize login checks across controllers - Replace custom `AccessDeniedRedirectException` with built-in `RedirectException` Employees: - Add `DISALLOW_PASSWORD_CHANGE` and `DISALLOW_GRANT_CHANGE` env vars to restrict credential and permission changes in locked-down environments - Extract `hasGrantsChanged()` to streamline `postSave` Refactor: - Rename snake_case variables to camelCase in Sales, Items, and Employees controllers for PSR-12 compliance - Use explicit `db_connect()` for transaction clarity in Items controller Fixes: - SMTP config entries fall back to defaults via null coalescing - Migration uses `DROP FOREIGN KEY` instead of `DROP CONSTRAINT` - Password hash upgrade only sets session on successful `hash_version` update - Correct lang key for unknown error in Module model Language: - Translate `error_grant_change_disallowed` / `error_password_change_disallowed` across all 44 supported locales with => alignment matching en reference - Fix "cannot be deleted" messages and misc typos across ~15 language files Tests: - Bootstrap seeder only once in ItemsCsvImportTest; close connection after - Restore `DISALLOW_GRANT_CHANGE` in teardown to prevent side effects - Use `uniqid()` for test user data to avoid collisions Signed-off-by: 17935339+objecttothis@users.noreply.github.com
54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Models\Employee;
|
|
use App\Models\Module;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Config\OSPOS;
|
|
|
|
/**
|
|
* Part of the grants mechanism to restrict access to modules that the user doesn't have permission for.
|
|
* Instantiated in the views.
|
|
*
|
|
* @property module module
|
|
*/
|
|
class No_access extends BaseController
|
|
{
|
|
private Employee $employee;
|
|
private Module $module;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->employee = model(Employee::class);
|
|
$this->module = model(Module::class);
|
|
}
|
|
|
|
/**
|
|
* @param string $module_id
|
|
* @param string $permission_id
|
|
* @return string
|
|
*/
|
|
public function getIndex(string $module_id = '', string $permission_id = ''): string
|
|
{
|
|
$data['module_name'] = $this->module->get_module_name($module_id);
|
|
$data['permission_id'] = $permission_id;
|
|
|
|
$userInfo = $this->employee->get_logged_in_employee_info();
|
|
if ($userInfo === false) {
|
|
return view('no_access', $data);
|
|
}
|
|
|
|
$menuGroup = session()->get('menu_group');
|
|
$allowedModules = $menuGroup == 'home'
|
|
? $this->module->get_allowed_home_modules($userInfo->person_id)
|
|
: $this->module->get_allowed_office_modules($userInfo->person_id);
|
|
|
|
$data['user_info'] = $userInfo;
|
|
$data['allowed_modules'] = $allowedModules->getResult();
|
|
$data['config'] = config(OSPOS::class)->settings;
|
|
|
|
return view('partial/header', $data) . view('no_access', $data) . view('partial/footer');
|
|
}
|
|
}
|