CodeIgniter Forums
auth_override_class_method_http not working with HMVC - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forum-7.html)
+--- Forum: Addins (https://forum.codeigniter.com/forum-13.html)
+--- Thread: auth_override_class_method_http not working with HMVC (/thread-74875.html)



auth_override_class_method_http not working with HMVC - harshalone - 11-19-2019

Hi I have a config setting like below:

Code:
$config['auth_override_class_method_http']['admin']['auth']['post'] = 'none';

I am using this library for my HMVC: https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

But when I checked with error handling on REST_Controller.php

it seems like /admin/auth is not recognised with REST

here is my REST code:
Code:
<?php
use Restserver\Libraries\REST_Controller;
defined('BASEPATH') OR exit('No direct script access allowed');
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
//To Solve File REST_Controller not found
require APPPATH . 'libraries/REST_Controller.php';
require APPPATH . 'libraries/Format.php';

class Auth extends REST_Controller {

    function __construct()
    {
        // Construct the parent class
        parent::__construct();

        $this->load->model('Auth_model', 'Entity_model');
        //$this->load->library('form_validation');
        $this->load->library('validation');

        header('Access-Control-Allow-Origin: *');
        header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");



    }


    public function index_get()
    {


      $return_message = [
                         'error' => 102,  
                         'message' => "Entity Not Found"
                        ];
      $this->set_response($return_message, REST_Controller::HTTP_NOT_FOUND);  

    }


    public function index_post()
    {
        /* Request, Response https://i.vgy.me/APy9PT.png */


            $message = [
                'status' => true,
                'error_code' => 102,  
                'error_message' => 'success'
            ];

            $this->set_response($message, REST_Controller::HTTP_CREATED);
            // CREATED (201) being the HTTP response code

    }

}

Although all of my GET/POST requests are working fine as it should be on the endpoint.

Could anyone suggest what I should do in order to get it working i.e.,

I want to use authentication on several API request but not on admin/auth [POST]


RE: auth_override_class_method_http not working with HMVC - InsiteFX - 11-19-2019

You would need to also make the rest controller use HMVC.