Skip to content

Commit

Permalink
Apply "Use HTTP Basic Auth" flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeykalenyuk committed Sep 25, 2014
1 parent 8b25447 commit 50fc949
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/code/community/Tadic/AVP/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

class Tadic_AVP_Helper_Data extends Mage_Core_Helper_Abstract
{

const XML_PATH_HTTP_BASIC_AUTH_ENABLED = 'catalog/productpreview/http_basic_auth';
}
22 changes: 12 additions & 10 deletions app/code/community/Tadic/AVP/controllers/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ public function preDispatch()
{
parent::preDispatch();

if (empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW'])) {
$this->_requestAuthentication();
}
if (Mage::getStoreConfigFlag(Tadic_AVP_Helper_Data::XML_PATH_HTTP_BASIC_AUTH_ENABLED)) {
if (empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW'])) {
$this->_requestAuthentication();
}

try {
$user = Mage::getModel('admin/user'); /** @var $user Mage_Admin_Model_User */
if ( ! $user->authenticate($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
Mage::throwException($this->__('Invalid login.'));
try {
$user = Mage::getModel('admin/user'); /** @var $user Mage_Admin_Model_User */
if ( ! $user->authenticate($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
Mage::throwException($this->__('Invalid login.'));
}
}
catch (Exception $e) {
$this->_requestAuthentication($e->getMessage());
}
}
catch (Exception $e) {
$this->_requestAuthentication($e->getMessage());
}
}

Expand Down

0 comments on commit 50fc949

Please sign in to comment.