Admin logout is not working properly after override of adminhtml controller
-
16-10-2019 - |
문제
I had override admin user controller, it was working fine but when I click on logout link page is not redirecting to admin login page.page is redirecting on front side.
Front screen shot http://postimg.org/image/71bshl9ar/
Override code.
<admin>
<routers>
<adminhtml>
<args>
<modules>
<FME_Bookingreservation before="Mage_Adminhtml">FME_Bookingreservation</FME_Bookingreservation>
</modules>
</args>
</adminhtml>
</routers>
</admin>
Controller code:
require_once 'Mage/Adminhtml/controllers/Permissions/UserController.php';
class FME_Bookingreservation_Permissions_UserController extends Mage_Adminhtml_Permissions_UserController
{
public function saveAction()
{
if ($data = $this->getRequest()->getPost()) {
$data['workshop_id'] = implode(',', $data['workshop_id']);
$id = $this->getRequest()->getParam('user_id');
$model = Mage::getModel('admin/user')->load($id);
if (!$model->getId() && $id) {
Mage::getSingleton('adminhtml/session')->addError($this->__('This user no longer exists.'));
$this->_redirect('*/*/');
return;
}
$model->setData($data);
/*
* Unsetting new password and password confirmation if they are blank
*/
if ($model->hasNewPassword() && $model->getNewPassword() === '') {
$model->unsNewPassword();
}
if ($model->hasPasswordConfirmation() && $model->getPasswordConfirmation() === '') {
$model->unsPasswordConfirmation();
}
$result = $model->validate();
if (is_array($result)) {
Mage::getSingleton('adminhtml/session')->setUserData($data);
foreach ($result as $message) {
Mage::getSingleton('adminhtml/session')->addError($message);
}
$this->_redirect('*/*/edit', array('_current' => true));
return $this;
}
try {
$model->save();
$workshop_collection = Mage::getModel('bookingreservation/staffmembers')->getCollection()->addFieldToFilter('workshop_admin_user_id',$model->getUserId());
foreach($workshop_collection as $collection)
{
$workshop = Mage::getModel('bookingreservation/staffmembers')->load($collection->getStaffmembers_id());
$workshop->setWorkshopAdminUserId(1);
$workshop->save();
}
foreach($this->getRequest()->getPost('workshop_id') as $w_id)
{
$workshop = Mage::getModel('bookingreservation/staffmembers')->load($w_id);
$workshop->setWorkshopAdminUserId($model->getUserId());
$workshop->save();
}
if ( $uRoles = $this->getRequest()->getParam('roles', false) ) {
/*parse_str($uRoles, $uRoles);
$uRoles = array_keys($uRoles);*/
if ( 1 == sizeof($uRoles) ) {
$model->setRoleIds($uRoles)
->setRoleUserId($model->getUserId())
->saveRelations();
} else if ( sizeof($uRoles) > 1 ) {
//@FIXME: stupid fix of previous multi-roles logic.
//@TODO: make proper DB upgrade in the future revisions.
$rs = array();
$rs[0] = $uRoles[0];
$model->setRoleIds( $rs )->setRoleUserId( $model->getUserId() )->saveRelations();
}
}
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The user has been saved.'));
Mage::getSingleton('adminhtml/session')->setUserData(false);
$this->_redirect('*/*/');
return;
} catch (Mage_Core_Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setUserData($data);
$this->_redirect('*/*/edit', array('user_id' => $model->getUserId()));
return;
}
}
$this->_redirect('*/*/');
}
}
해결책
The most common cause of something like this is the logout URL
http://magento.example.com/index.php/admin/index/logout/key/9f874d25529246149a02320fa07aecd1/
is matching some other controller and NOT the
app/code/core/Mage/Adminhtml/controllers/IndexController.php
file with the logout logic. Does your module have an IndexController
file? If so, remove it, because when you said
<FME_Bookingreservation before="Mage_Adminhtml">
you told Magento to look in your module for admin
controllers first.
제휴하지 않습니다 magento.stackexchange