Magento Login Authorization API

Is there any Api for authenticating the administrator login in Magento ?.

+4
source share
3 answers

I think magento has extensions for admin authentication. This may help you.

+4
source
if(isset($_REQUEST['admin_name']) && isset($_REQUEST['admin_password'])) $user = Mage::getModel('admin/user'); $user->login($_REQUEST['admin_name'],$_REQUEST['admin_password']); $result=$user->getId(); if($result) { $result1=$user->getUsername(); $result2=$user->getFirstname(); $result3=$user->getLastname(); $result4= $user->getEmail(); echo $result4; } 
+3
source

It is not clear what you want to achieve. Therefore, I made recommendations for three possible goals.


1) If you want to authenticate the administrator through any third-party system , so he does not need to enter his credentials in the standard "Login / Password" form , then you need to attract Magento code flexibility> and install some kind of custom solution or write it by yourself. There is no third-party authentication feature out of the box because it is too specialized and there are many auth providers / APIs.

Like any system, Magento cannot be the Swiss knife for everything, providing all the solutions with the original system package. Instead, the platform comes with many useful e-commerce features and the ability to fully customize. Thus, if any store owner wants a new feature for his store, he can easily develop his own solution. Or try to find it in Magento Connect (e.g. Magento App Store), a link to which has already been provided by @naveen.


2) If you want to use the API to perform some actions with the backend (creating a product, managing clients, etc.) as an administrator user, then you can use the Magento REST or SOAP APIs. Please note that these systems do not use administrator accounts, and they have their own users who are configured for the backend. You can find more information on the Magento API in the official documentation .


3) If you want to use the internal API to check the administrator login and password in PHP, you should use Mage_Admin_Model_User or Mage_Admin_Model_Session for this.

For authentication, there are two methods for Mage_Admin_Model_User :

  • authenticate($username, $password) - loads the user model, whether authentication returns
 $adminUser = Mage::getModel('admin/user'); if ($adminUser->authenticate($username, $password)) { echo 'Success'; } else { echo 'Failure'; } 
  • login($username, $password) - loads the user model, failed log authentication attempts.
 $adminUser = Mage::getModel('admin/user'); $adminUser->login($username, $password) if ($adminUser->getId()) { echo 'Success'; } else { echo 'Failure'; } 

And there is one method in Mage_Admin_Model_Session - login($username, $password) . The model itself is designed to control the administrator’s session - run it upon successful login, configure cookies in the browser, allow the administrator to view the backend after logging in. The login() method starts a new session and returns the user model if the login was successful.

 $adminSession = Mage::getSingleton('admin/session'); $adminUser = $adminSession->login($username, $password) if ($adminUser) { echo 'Success'; } else { echo 'Failure'; } 
+1
source

All Articles