Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement #4

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply "Use HTTP Basic Auth" flag.
  • Loading branch information
sergeykalenyuk committed Sep 25, 2014
commit 50fc949641efe86a68a50937cb9535d647ece936
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