Files
wevads-platform/app/controllers/GsuiteAccounts.php
2026-02-26 03:06:17 +01:00

91 lines
2.4 KiB
PHP

<?php declare(strict_types=1); namespace IR\App\Controllers; if (!defined('IR_START')) exit('<pre>No direct script access allowed</pre>');
use IR\Core\Application as Application;
use IR\Mvc\Controller as Controller;
use IR\Http\Request as Request;
use IR\App\Helpers\Authentication as Authentication;
use IR\App\Helpers\Page as Page;
use IR\App\Helpers\Permissions as Permissions;
use IR\Exceptions\Types\PageException as PageException;
/**
* @name GsuiteAccounts
* @description GsuiteAccounts Controller
*/
class GsuiteAccounts extends Controller
{
/**
* @app
* @readwrite
*/
protected $app;
/**
* @app
* @readwrite
*/
protected $authenticatedUser;
/**
* @name init
* @description initializing process before the action method executed
* @once
* @protected
*/
public function init()
{
$this->app = Application::getCurrent();
$this->app->database('system')->connect();
if(!Authentication::isUserAuthenticated()) {
Page::redirect($this->app->http->request->getBaseURL() . RDS . 'auth' . RDS . 'login.' . DEFAULT_EXTENSION);
}
Authentication::checkUserRoles();
$this->authenticatedUser = Authentication::getAuthenticatedUser();
}
/**
* @name main
* @description the main action
* @before init
* @after closeConnections,checkForMessage
*/
public function main()
{
$access = Permissions::checkForAuthorization($this->authenticatedUser,__CLASS__,__FUNCTION__);
if($access == false) throw new PageException('Access Denied !',403);
}
/**
* @name add
* @description the add action
* @before init
* @after closeConnections,checkForMessage
*/
public function add()
{
$access = Permissions::checkForAuthorization($this->authenticatedUser,__CLASS__,'main');
if($access == false) throw new PageException('Access Denied !',403);
}
/**
* @name closeConnections
* @description close all connections
* @once
* @protected
*/
public function closeConnections()
{
$this->app->database('system')->disconnect();
}
/**
* @name checkForMessage
* @description checks for session messages
* @once
* @protected
*/
public function checkForMessage()
{
Page::checkForMessage($this);
}
}