0

I tried to access the Admin Controller without Login, it redirects me to Admin login page. I added below function in my custom controller, but it is not working.

public function preDispatch()
    {
        Mage::app()->getRequest()->setParam('forwarded', true );
        return parent::preDispatch();
    }

Can anyone please suggest, how to make it work.

I tried to rewrite it is not working,

require_once "Mage/Adminhtml/controllers/IndexController.php";

class Namespace_Modulename_Adminhtml_SchooladminController extends Mage_Adminhtml_IndexController
{
    public function loginAction()
    {
        if (Mage::getSingleton('admin/session')->isLoggedIn()) {
            $this->_redirect('*');
            return;
        }

        $loginData = $this->getRequest()->getParam('login');
        $username = (is_array($loginData) && array_key_exists('username', $loginData)) ? $loginData['username'] : null;
        echo 'Override';
        exit;
        $this->loadLayout();
        $this->renderLayout();
    }
}
7
  • login is mandatory to access admin panel. why you want this ? use front controller instead Commented Aug 2, 2016 at 5:30
  • I want to use my custom module controller for admin Login page, so url will be my custom controller
    – user2520
    Commented Aug 2, 2016 at 5:31
  • you mean to overwrite login page ? Commented Aug 2, 2016 at 5:34
  • yes correct Minesh
    – user2520
    Commented Aug 2, 2016 at 5:35
  • try to rewrite app/code/core/Mage/Adminhtml/controllers/IndexController.php Commented Aug 2, 2016 at 5:41

1 Answer 1

0

If you need to make your custom admin controller public (i.e. without requiring login, using cookies, etc.), just add this part of code into your controller class:

protected function _rewrite() {
    return true;
}

Or you can override the preDispatch() method instead (copy as much stuff as you need from all parents and don't call parent in your method).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.