auth_override_class_method_http不适用于HMVC

问题描述 投票:0回答:1

嗨,我有如下配置设置:

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

我正在将此库用于HMVC:https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

但是当我检查REST_Controller.php的错误处理时>

似乎REST无法识别/ admin / auth

这是我的REST代码:

<?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

    }



}

尽管我的所有GET / POST请求都可以正常工作,因为它应该在端点上。

有人可以建议我该怎么做才能使它正常工作,]

我想对多个API请求使用身份验证,但不对admin / auth [POST]使用身份验证>

嗨,我的配置设置如下:$ config ['auth_override_class_method_http'] ['admin'] ['auth'] ['post'] ='none';我正在为我的HMVC使用此库:https://bitbucket.org/wiredesignz / ...

codeigniter restful-authentication hmvc
1个回答
0
投票

经过几天的调试,我意识到由于我使用的是HMVC,REST_Controller中的路由器类未获得正确的索引。

所以我编辑了REST_controller以与HMVC一起使用

© www.soinside.com 2019 - 2024. All rights reserved.