Welcome Guest, Not a member yet? Register   Sign In
Filters and $_POST (or $request post vars)
#4

[quote pid="389059" dateline="1627911401"]
you need api ctl other ctl extend from it  after log in call $userId
[/quote]
you dont need add data to post request

PHP Code:
<?php

namespace Modules\Shared\Controllers;

/**
 * Class BaseController
 *
 * BaseController provides a convenient place for loading components
 * and performing functions that are needed by all your controllers.
 * Extend this class in any new controllers:
 *    class Home extends BaseController
 *
 * For security be sure to declare any new methods as protected or private.
 *
 * @package CodeIgniter
 */


use CodeIgniter\HTTP\RequestInterface;
use 
CodeIgniter\HTTP\ResponseInterface;
use 
CodeIgniter\RESTful\ResourceController;
use 
Myth\Auth\AuthTrait;
use 
Psr\Log\LoggerInterface;
use  Modules\Shared\Interfaces\UrlQueryParamInterface;
use  Modules\Shared\Libraries\UrlQueryParam;

class 
ApiController extends ResourceController
{
    use AuthTrait;

    protected $format "";

    public int $userId;
    public object $userObject;
    public array $userGroup;
    public UrlQueryParamInterface $urlQueryParam;

    /**
    * An array of helpers to be loaded automatically upon
    * class instantiation. These helpers will be available
    * to all other controllers that extend BaseController.
    *
    * @var array
    */
    protected $helpers = ['cookie''url''from''filesystem','text'];

    /**
    * Constructor.
    *
    * @param RequestInterface $request
    * @param ResponseInterface $response
    * @param LoggerInterface $logger
    */


    /**
    * @var string
    * Holds the session instance
    */
    protected $session;

    public function __construct()
    {
        $this->userId 0;
        $this->userGroup = [];
        $this->userObject = (object)[];
    }

    public function initController(RequestInterface $requestResponseInterface $responseLoggerInterface $logger)
    {
        // Do Not Edit This Line
        parent::initController($request$response$logger);

        try {
            $this->setupAuthClasses();
            if ($this->authenticate->check()) {
                $this->userId $this->authenticate->id();
                $this->userObject $this->authenticate->user();
                $groupModel = new \Myth\Auth\Authorization\GroupModel();
                $this->userGroup $groupModel->getGroupsForUser($this->userId)[0];

            }
            $this->urlQueryParam = new UrlQueryParam();
            $this->urlQueryParam->initParameters($request);

        } catch (\Exception $e) {

        }
    }


Enlightenment  Is  Freedom
Reply


Messages In This Thread
RE: Filters and $_POST (or $request post vars) - by paliz - 08-02-2021, 10:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB