add user authentification

Cette révision appartient à :
Daniel Seifert 2017-11-21 16:35:36 +01:00
Parent a136926975
révision f46ac0e6da
4 fichiers modifiés avec 104 ajouts et 1 suppressions

Voir le fichier

@ -16,6 +16,58 @@
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()
{
header('Content-type: text/html; charset='.oxRegistry::getLang()->translateString('charset'));

Voir le fichier

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

Voir le fichier

@ -31,12 +31,58 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent
&& false == (bool) oxRegistry::getConfig()->getActiveShop()->oxshops__oxproductive->value
&& oxRegistry::getConfig()->getConfigParam('blD3DevShowThankyou')
) {
$this->_d3authenticate();
$oOrder = $this->d3GetLastOrder();
$oBasket = $oOrder->d3DevGetOrderBasket();
$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
*/

Voir le fichier

@ -1,6 +1,11 @@
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.
=> 1.2.0.0
- Dokuemntation ergänzt
- Mail-Anzeige fordert zusätzlich Authentfikation mit einem Shopadmin-Konto
- Seitenencoding definiert
=> 1.1.0.0
- Mailversand übers Shopframework wird blockiert oder
- Mails werden an alternative Mailadresse umgeleitet