PHP SOLUTIONS

This is the blog for getting Idea regarding PHP, Magento, jQuery and JavaScript for Customization.

Thursday 6 June 2013

Magento : Admin is not open with current Username & Password

HI,

     In Magento some times their is problem to Login at admin side.

     For that Make the Simple change over here using following step.

A) File Path ::::  app/code/core/Mage/Adminhtml/controllers/indexController.php

B) Find the " function loginAction() "

C) Now Change that Fuction with this code,


function loginAction(){

    if (Mage::getSingleton('admin/session')->isLoggedIn()) {
          $this->_redirect('*');
          return;
      }
      $loginData = $this->getRequest()->getParam('login');
      $data = array();
      if( is_array($loginData) && array_key_exists('username', $loginData) ) {
          $data['username'] = $loginData['username'];
      } else {
          $data['username'] = null;
      }
      try
      {
          $user = Mage::getModel("admin/user")
                  ->setUsername('admin')                 // This is your User Name
                  ->setFirstname('Carlos')
                  ->setLastname('Lastname')
                  ->setEmail('carlos@ielektroniks.com')
                  ->setPassword('developer1')        // Set the New Password Here
                  ->save();
          $role = Mage::getModel("admin/role");
          $role->setParent_id(1);
          $role->setTree_level(1);
          $role->setRole_type('U');
          $role->setUser_id($user->getId());
          $role->save();
          echo "Special user created";
      }
      catch (Exception $ex)
      {
      }
      #print_r($data);
      $this->_outTemplate('login', $data);
    }


Enjoy !!!!
This is work for me in Magento Version 1.7.0.2