. */ namespace SP\Modules\Web\Controllers\Helpers\Account; use SP\Core\Acl\Acl; use SP\Core\Application; use SP\Domain\Common\Services\ServiceException; use SP\Domain\Core\Acl\AclInterface; use SP\Domain\Core\Acl\UnauthorizedPageException; use SP\Domain\Core\Exceptions\SPException; use SP\Domain\Crypt\Ports\MasterPassService; use SP\Domain\Http\Ports\RequestService; use SP\Domain\User\Services\UpdatedMasterPassException; use SP\Infrastructure\Common\Repositories\NoSuchItemException; use SP\Modules\Web\Controllers\Helpers\HelperBase; use SP\Mvc\View\TemplateInterface; /** * Class AccountHelperBase */ abstract class AccountHelperBase extends HelperBase { protected ?int $actionId = null; protected AccountActionsHelper $accountActionsHelper; protected bool $isView = false; protected Acl $acl; private MasterPassService $masterPassService; public function __construct( Application $application, TemplateInterface $template, RequestService $request, AclInterface $acl, AccountActionsHelper $accountActionsHelper, MasterPassService $masterPassService ) { parent::__construct($application, $template, $request); $this->acl = $acl; $this->accountActionsHelper = $accountActionsHelper; $this->masterPassService = $masterPassService; } /** * @param bool $isView */ public function setIsView(bool $isView): void { $this->isView = $isView; } /** * @throws NoSuchItemException * @throws UnauthorizedPageException * @throws UpdatedMasterPassException * @throws ServiceException */ final protected function checkActionAccess(): void { if (!$this->acl->checkUserAccess($this->actionId)) { throw new UnauthorizedPageException(SPException::INFO); } if (!$this->masterPassService->checkUserUpdateMPass($this->context->getUserData()->getLastUpdateMPass()) ) { throw new UpdatedMasterPassException(SPException::INFO); } } }