00001 <?php
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 class Mage_Rss_Helper_Data extends Mage_Core_Helper_Abstract
00036 {
00037 
00038 
00039 
00040 
00041     public function authFrontend()
00042     {
00043         $session = Mage::getSingleton('rss/session');
00044         if ($session->isCustomerLoggedIn()) {
00045             return;
00046         }
00047         list($username, $password) = $this->authValidate();
00048         $customer = Mage::getModel('customer/customer')->authenticate($username, $password);
00049         if ($customer && $customer->getId()) {
00050             Mage::getSingleton('rss/session')->settCustomer($customer);
00051         } else {
00052             $this->authFailed();
00053         }
00054     }
00055 
00056 
00057 
00058 
00059 
00060 
00061     public function authAdmin($path)
00062     {
00063         $session = Mage::getSingleton('rss/session');
00064         if ($session->isAdminLoggedIn()) {
00065             return;
00066         }
00067         list($username, $password) = $this->authValidate();
00068         Mage::getSingleton('adminhtml/url')->setNoSecret(true);
00069         $adminSession = Mage::getModel('admin/session');
00070         $user = $adminSession->login($username, $password);
00071         
00072         if($user && $user->getId() && $user->getIsActive() == '1' && $adminSession->isAllowed($path)){
00073             $session->setAdmin($user);
00074         } else {
00075             $this->authFailed();
00076         }
00077     }
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085     public function authValidate($headers=null)
00086     {
00087         $userPass = Mage::helper('core/http')->authValidate($headers);
00088         return $userPass;
00089     }
00090 
00091 
00092 
00093 
00094 
00095     public function authFailed()
00096     {
00097         Mage::helper('core/http')->authFailed();
00098     }
00099 }