8
0
Fork 0

add user authentification

Dieser Commit ist enthalten in:
Daniel Seifert 2017-11-21 16:35:36 +01:00
Ursprung a136926975
Commit f46ac0e6da
4 geänderte Dateien mit 104 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -16,6 +16,58 @@
class d3dev extends oxUBase class d3dev extends oxUBase
{ {
public function init()
{
$this->_authenticate();
parent::init();
}
protected function _authenticate ()
{
$oConfig = oxRegistry::getConfig();
try {
$sUser = $oConfig->getRequestParameter( 'usr' );
$sPassword = $oConfig->getRequestParameter( 'pwd' );
if ( !$sUser || !$sPassword ) {
$sUser = $_SERVER[ 'PHP_AUTH_USER' ];
$sPassword = $_SERVER[ 'PHP_AUTH_PW' ];
}
if ( !$sUser || !$sPassword ) {
$sHttpAuthorization = $_REQUEST[ 'HTTP_AUTHORIZATION' ];
if ( $sHttpAuthorization ) {
$sUser = null;
$sPassword = null;
$aHttpAuthorization = explode( ' ', $sHttpAuthorization );
if ( is_array( $aHttpAuthorization ) && count( $aHttpAuthorization ) >= 2 && strtolower( $aHttpAuthorization[ 0 ] ) == 'basic' ) {
$sBasicAuthorization = base64_decode( $aHttpAuthorization[ 1 ] );
$aBasicAuthorization = explode( ':', $sBasicAuthorization );
if ( is_array( $aBasicAuthorization ) && count( $aBasicAuthorization ) >= 2 ) {
$sUser = $aBasicAuthorization[ 0 ];
$sPassword = $aBasicAuthorization[ 1 ];
}
}
}
}
/** @var oxUser $oUser */
$oUser = oxNew( 'oxuser' );
if ( !$sUser || !$sPassword || !$oUser->login( $sUser, $sPassword ) ) {
$oEx = oxNew( 'oxuserexception' );
$oEx->setMessage( 'EXCEPTION_USER_NOVALIDLOGIN' );
throw $oEx;
}
}
catch ( Exception $oEx ) {
$oShop = $oConfig->getActiveShop();
header( 'WWW-Authenticate: Basic realm="' . $oShop->oxshops__oxname->value . '"' );
header( 'HTTP/1.0 401 Unauthorized' );
exit( 1 );
}
}
public function showOrderMailContent() public function showOrderMailContent()
{ {
header('Content-type: text/html; charset='.oxRegistry::getLang()->translateString('charset')); header('Content-type: text/html; charset='.oxRegistry::getLang()->translateString('charset'));

Datei anzeigen

@ -45,7 +45,7 @@ $aModule = array(
'* Ordernummer an URL ergänzen, wenn bestimmte Bestellungen angezeigt werden sollen', '* Ordernummer an URL ergänzen, wenn bestimmte Bestellungen angezeigt werden sollen',
'en' => ''), 'en' => ''),
// 'thumbnail' => 'picture.png', // 'thumbnail' => 'picture.png',
'version' => '1.1', 'version' => '1.2.0.0',
'author' => 'D³ Data Development (Inh.: Thomas Dartsch)', 'author' => 'D³ Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com', 'email' => 'support@shopmodule.com',
'url' => 'http://www.oxidmodule.com/', 'url' => 'http://www.oxidmodule.com/',

Datei anzeigen

@ -31,12 +31,58 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent
&& false == (bool) oxRegistry::getConfig()->getActiveShop()->oxshops__oxproductive->value && false == (bool) oxRegistry::getConfig()->getActiveShop()->oxshops__oxproductive->value
&& oxRegistry::getConfig()->getConfigParam('blD3DevShowThankyou') && oxRegistry::getConfig()->getConfigParam('blD3DevShowThankyou')
) { ) {
$this->_d3authenticate();
$oOrder = $this->d3GetLastOrder(); $oOrder = $this->d3GetLastOrder();
$oBasket = $oOrder->d3DevGetOrderBasket(); $oBasket = $oOrder->d3DevGetOrderBasket();
$this->_oBasket = $oBasket; $this->_oBasket = $oBasket;
} }
} }
protected function _d3authenticate ()
{
$oConfig = oxRegistry::getConfig();
try {
$sUser = $oConfig->getRequestParameter( 'usr' );
$sPassword = $oConfig->getRequestParameter( 'pwd' );
if ( !$sUser || !$sPassword ) {
$sUser = $_SERVER[ 'PHP_AUTH_USER' ];
$sPassword = $_SERVER[ 'PHP_AUTH_PW' ];
}
if ( !$sUser || !$sPassword ) {
$sHttpAuthorization = $_REQUEST[ 'HTTP_AUTHORIZATION' ];
if ( $sHttpAuthorization ) {
$sUser = null;
$sPassword = null;
$aHttpAuthorization = explode( ' ', $sHttpAuthorization );
if ( is_array( $aHttpAuthorization ) && count( $aHttpAuthorization ) >= 2 && strtolower( $aHttpAuthorization[ 0 ] ) == 'basic' ) {
$sBasicAuthorization = base64_decode( $aHttpAuthorization[ 1 ] );
$aBasicAuthorization = explode( ':', $sBasicAuthorization );
if ( is_array( $aBasicAuthorization ) && count( $aBasicAuthorization ) >= 2 ) {
$sUser = $aBasicAuthorization[ 0 ];
$sPassword = $aBasicAuthorization[ 1 ];
}
}
}
}
/** @var oxUser $oUser */
$oUser = oxNew( 'oxuser' );
if ( !$sUser || !$sPassword || !$oUser->login( $sUser, $sPassword ) ) {
$oEx = oxNew( 'oxuserexception' );
$oEx->setMessage( 'EXCEPTION_USER_NOVALIDLOGIN' );
throw $oEx;
}
}
catch ( Exception $oEx ) {
$oShop = $oConfig->getActiveShop();
header( 'WWW-Authenticate: Basic realm="' . $oShop->oxshops__oxname->value . '"' );
header( 'HTTP/1.0 401 Unauthorized' );
exit( 1 );
}
}
/** /**
* @return d3_dev_oxorder * @return d3_dev_oxorder
*/ */

Datei anzeigen

@ -1,6 +1,11 @@
Hinweise zur Benutzung und Konfiguration sind in der Metadata-Modulbeschreibung enthalten. Hinweise zur Benutzung und Konfiguration sind in der Metadata-Modulbeschreibung enthalten.
Diese können nach Installation im Backend des OXID-Shops unter "Erweiterungen -> Module" eingesehen werden. Diese können nach Installation im Backend des OXID-Shops unter "Erweiterungen -> Module" eingesehen werden.
=> 1.2.0.0
- Dokuemntation ergänzt
- Mail-Anzeige fordert zusätzlich Authentfikation mit einem Shopadmin-Konto
- Seitenencoding definiert
=> 1.1.0.0 => 1.1.0.0
- Mailversand übers Shopframework wird blockiert oder - Mailversand übers Shopframework wird blockiert oder
- Mails werden an alternative Mailadresse umgeleitet - Mails werden an alternative Mailadresse umgeleitet