0

I'm trying to add a form to the admin login. I just get a 404 currently but this is where I'm sending the user:

http://local.mage.dev/index.php/wsu_adminldap/index/requestaccess/

I have the controller app\code\local\Wsu\Adminldap\controllers\IndexController.php

<?
class Wsu_Adminldap_IndexController extends Mage_Adminhtml_IndexController {

        public function indexAction(){
            $this->loadLayout();
            $this->renderLayout();      
        }

    /**
     * Forgot administrator password action
     * Request Access 
     */
    public function requestaccessAction() {
        $email    = (string) $this->getRequest()->getParam('email');
        $store_id = (string) $this->getRequest()->getParam('store');
        $params   = $this->getRequest()->getParams();
        if (!empty($email) && !empty($params)) {
            $this->_getSession()->addError($this->__('This account already exists.'));  

        } elseif (!empty($params)) {
            $this->_getSession()->addError(Mage::helper('adminhtml')->__('The email address is empty.'));
        }
        $this->loadLayout();
        $this->renderLayout();
    }
}

and the config.xml

<?xml version="1.0" encoding="utf-8"?>
<config>
  <modules>
    <Wsu_Adminldap>
      <version>0.1.0</version>
    </Wsu_Adminldap>
  </modules>
  <global>
    <helpers>
      <wsu_adminldap>
        <class>Wsu_Adminldap_Helper</class>
      </wsu_adminldap>
    </helpers>
    <blocks>
      <wsu_adminldap>
        <class>Wsu_Adminldap_Block</class>
      </wsu_adminldap>
    </blocks>
    <models>
      <wsu_adminldap>
        <class>Wsu_Adminldap_Model</class>
      </wsu_adminldap>
      <admin>
        <rewrite>
          <session>Wsu_Adminldap_Model_Session</session>
          <Observer>Wsu_Adminldap_Model_Observer</Observer>
        </rewrite>
      </admin>
    </models>
  </global>
  <admin>
    <routers>
      <adminhtml>
        <args>
          <modules>
            <wsu_adminldap before="Mage_Adminhtml">Wsu_Adminldap_Adminhtml</wsu_adminldap>
          </modules>
        </args>
      </adminhtml>
    </routers>
  </admin>
</config>

and the view app\design\adminhtml\default\default\template\wsu\adminldap\requestaccess.phtml

<?php
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?php echo Mage::helper('adminhtml')->__('Log into Magento Admin Page'); ?></title>
    <link type="text/css" rel="stylesheet" href="<?php echo $this->getSkinUrl('reset.css'); ?>" media="all" />
    <link type="text/css" rel="stylesheet" href="<?php echo $this->getSkinUrl('boxes.css'); ?>" media="all" />
    <link rel="icon" href="<?php echo $this->getSkinUrl('favicon.ico'); ?>" type="image/x-icon" />
    <link rel="shortcut icon" href="<?php echo $this->getSkinUrl('favicon.ico'); ?>" type="image/x-icon" />

    <script type="text/javascript" src="<?php echo $this->getJsUrl(); ?>index.php/x.js?f=prototype/prototype.js,prototype/validation.js,mage/adminhtml/events.js,mage/adminhtml/form.js,scriptaculous/effects.js"></script>
    <script type="text/javascript" src="<?php echo $this->getJsUrl('mage/captcha.js') ?>"></script>

    <!--[if IE]> <link rel="stylesheet" href="<?php echo $this->getSkinUrl('iestyles.css'); ?>" type="text/css" media="all" /> <![endif]-->
    <!--[if lt IE 7]> <link rel="stylesheet" href="<?php echo $this->getSkinUrl('below_ie7.css'); ?>" type="text/css" media="all" /> <![endif]-->
    <!--[if IE 7]> <link rel="stylesheet" href="<?php echo $this->getSkinUrl('ie7.css'); ?>" type="text/css" media="all" /> <![endif]-->
</head>
<body id="page-login">
    <div class="login-container">
        <div class="login-box">
            <form method="post" action="" id="loginForm">
                <fieldset class="login-form">
                    <input name="form_key" type="hidden" value="<?php echo $this->getFormKey(); ?>" />
                    <h2><?php echo Mage::helper('adminhtml')->__('Forgot your user name or password?'); ?></h2>
                    <div id="messages">
                        <?php echo $this->getMessagesBlock()->getGroupedHtml(); ?>
                    </div>
                    <div class="input-box forgot-password"><label for="email"><?php echo Mage::helper('adminhtml')->__('Email Address:'); ?></label><br />
                        <input type="text" id="email" name="email" value="" class="required-entry input-text forgot-password validate-email" style="width:461px;" />
                    </div>
                    <?php echo $this->getChildHtml('form.additional.info'); ?>
                    <div class="clear"></div>
                    <div class="form-buttons">
                        <a class="left" href="<?php echo $this->getUrl('adminhtml', array('_nosecret' => true)); ?>">&laquo; <?php echo Mage::helper('adminhtml')->__('Back to Login'); ?></a>
                        <button class="forgot-password" onclick="loginForm.submit()" type="button"><span><?php echo Mage::helper('adminhtml')->__('Retrieve Password'); ?></span></button>
                    </div>
                </fieldset>
                <p class="login-support"><!-- --></p>
                <p class="legal"><?php echo Mage::helper('adminhtml')->__('Magento is a trademark of Magento Inc. Copyright &copy; %s Magento Inc.', date('Y')); ?></p>
            </form>
            <div class="bottom"></div>
            <script type="text/javascript">
                 var loginForm = new varienForm('loginForm');
            </script>
        </div>
    </div>
</body>
</html>

Am I missing or overlooking something to bring up the form?

1

You should put your controller in: app\code\local\Wsu\Adminldap\controllers\Adminhtml\WsuController.php

and then use the route:

http://local.mage.dev/index.php/admin/wsu/requestaccess/

This is because you define in your config.xml that your controller extends the adminhtml controller and runs before it using the path

<wsu_adminldap before="Mage_Adminhtml">Wsu_Adminldap_Adminhtml</wsu_adminldap>

So Magento looks in the folder app\code\local\Wsu\Adminldap\controllers\Adminhtml for anything served at http://local.mage.dev/index.php/admin/* where * is the name of the controller (above I said wsu, so you need a WsuController.php in that folder).

Make sure to rename the controller also in your php file from IndexController to WsuController!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.