Jump to content

Edit History

jayashanka

jayashanka

On 7/17/2023 at 1:33 PM, Kogkalidis said:

Hook::exec('actionObject' . $this->getFullyQualifiedName() . 'AddBefore', ['object' => $this]);

Hook::exec('actionObject' . $this->getFullyQualifiedName() . 'AddAfter', ['object' => $this]);

So in our case should be hook "actionObjectCustomerAddAfter".

The previously posted works afte some sort of control, so probably you don't pass that control.

Let me know about your progress.

 

 

<?php
 
use PrestaShop\PrestaShop\Core\Logger\LogManager;

class CustomAuthModule extends Module
{
    public function __construct()
    {
        $this->name = 'customauthmodule';
        $this->tab = 'others';
        $this->version = '1.0.0';
        $this->author = 'Amila Jayashanka';
        $this->need_instance = 0;
        
        parent::__construct();

        $this->displayName = $this->l('Custom Authentication Module');
        $this->description = $this->l('Custom module for integrating centralized authentication API.');

        $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
    }

    public function install()
    { 
        return parent::install() &&
        $this->registerHook('actionObjectCustomerAddAfter');
    }

    public function uninstall()
    { 
        return parent::uninstall();
    } 

    public function hookActionObjectCustomerAddAfter($params)
    {    
        LogManager::addLog('hookActionObjectCustomerAddAfter called', LogLevel::INFO, null, 'CustomAuthModule');

        $apiResponse = CustomAuthAPI::authenticateUser($params['customer']);
 
        if ($apiResponse->success) {
            // User authentication successful 
            //$this->storeUserData($apiResponse->data, $params['customer']);

     
        } else {
            // User authentication failed 
            $errorMessage = $apiResponse->message;
            $this->context->controller->errors[] = $this->l($errorMessage);
            $this->context->controller->redirectWithNotifications('index.php?controller=authentication');
        }
    }

    private function storeUserData($apiData, $customerData)
    {
        // Store additional user data in PrestaShop 
    }
}

@Kogkalidis Sorry I was not well last few days. Today I tested with  actionObjectCustomerAddAfter.  After registration submitted, I'm getting  below error, but user has registered successfully in prestashop database. 

 

This page isn’t working

iptest.isimaga.com is currently unable to handle this request.

HTTP ERROR 500

 

even log also not getting hit. 

This is registration URL https://iptest.isimaga.com/registration

We are using Prestashop 8.0

 

jayashanka

jayashanka

On 7/17/2023 at 1:33 PM, Kogkalidis said:

Hook::exec('actionObject' . $this->getFullyQualifiedName() . 'AddBefore', ['object' => $this]);

Hook::exec('actionObject' . $this->getFullyQualifiedName() . 'AddAfter', ['object' => $this]);

So in our case should be hook "actionObjectCustomerAddAfter".

The previously posted works afte some sort of control, so probably you don't pass that control.

Let me know about your progress.

 

 

<?php
 
use PrestaShop\PrestaShop\Core\Logger\LogManager;

class CustomAuthModule extends Module
{
    public function __construct()
    {
        $this->name = 'customauthmodule';
        $this->tab = 'others';
        $this->version = '1.0.0';
        $this->author = 'Amila Jayashanka';
        $this->need_instance = 0;
        
        parent::__construct();

        $this->displayName = $this->l('Custom Authentication Module');
        $this->description = $this->l('Custom module for integrating centralized authentication API.');

        $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
    }

    public function install()
    { 
        return parent::install() &&
        $this->registerHook('actionObjectCustomerAddAfter');
    }

    public function uninstall()
    { 
        return parent::uninstall();
    } 

    public function hookActionObjectCustomerAddAfter($params)
    {    
        LogManager::addLog('hookActionObjectCustomerAddAfter called', LogLevel::INFO, null, 'CustomAuthModule');

        $apiResponse = CustomAuthAPI::authenticateUser($params['customer']);
 
        if ($apiResponse->success) {
            // User authentication successful 
            //$this->storeUserData($apiResponse->data, $params['customer']);

     
        } else {
            // User authentication failed 
            $errorMessage = $apiResponse->message;
            $this->context->controller->errors[] = $this->l($errorMessage);
            $this->context->controller->redirectWithNotifications('index.php?controller=authentication');
        }
    }

    private function storeUserData($apiData, $customerData)
    {
        // Store additional user data in PrestaShop 
    }
}

@Kogkalidis Sorry I was not well last few days. Today I tested with  actionObjectCustomerAddAfter.  After registration submitted, I'm getting  below error, but user has registered successfully in prestashop database. 

 

This page isn’t working

iptest.isimaga.com is currently unable to handle this request.

HTTP ERROR 500

 

even log also not getting hit. 

This is registration URL https://iptest.isimaga.com/registration

jayashanka

jayashanka

On 7/17/2023 at 1:33 PM, Kogkalidis said:

Hook::exec('actionObject' . $this->getFullyQualifiedName() . 'AddBefore', ['object' => $this]);

Hook::exec('actionObject' . $this->getFullyQualifiedName() . 'AddAfter', ['object' => $this]);

So in our case should be hook "actionObjectCustomerAddAfter".

The previously posted works afte some sort of control, so probably you don't pass that control.

Let me know about your progress.

 

 

<?php
 
use PrestaShop\PrestaShop\Core\Logger\LogManager;

class CustomAuthModule extends Module
{
    public function __construct()
    {
        $this->name = 'customauthmodule';
        $this->tab = 'others';
        $this->version = '1.0.0';
        $this->author = 'Amila Jayashanka';
        $this->need_instance = 0;
        
        parent::__construct();

        $this->displayName = $this->l('Custom Authentication Module');
        $this->description = $this->l('Custom module for integrating centralized authentication API.');

        $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
    }

    public function install()
    { 
        return parent::install() &&
        $this->registerHook('actionObjectCustomerAddAfter');
    }

    public function uninstall()
    { 
        return parent::uninstall();
    } 

    public function hookActionObjectCustomerAddAfter($params)
    {    
        LogManager::addLog('hookActionObjectCustomerAddAfter called', LogLevel::INFO, null, 'CustomAuthModule');

        $apiResponse = CustomAuthAPI::authenticateUser($params['customer']);
 
        if ($apiResponse->success) {
            // User authentication successful 
            //$this->storeUserData($apiResponse->data, $params['customer']);

     
        } else {
            // User authentication failed 
            $errorMessage = $apiResponse->message;
            $this->context->controller->errors[] = $this->l($errorMessage);
            $this->context->controller->redirectWithNotifications('index.php?controller=authentication');
        }
    }

    private function storeUserData($apiData, $customerData)
    {
        // Store additional user data in PrestaShop 
    }
}

@Kogkalidis Sorry I was not well last few days. Today I tested with  actionObjectCustomerAddAfter.  After registration submitted, I'm getting  below error, but user has registered successfully in prestashop database. 

 

This page isn’t working

iptest.isimaga.com is currently unable to handle this request.

HTTP ERROR 500

 

even log also not getting hit. 

×
×
  • Create New...