Jump to content

how to override authcontroller.php


boxybh28

Recommended Posts

well okay i have read the prestashop manuals and it says either i put the over ride file in modules or the override directory so i made a file

 

prestashop\override\controllers\front\AuthController.php

 

 

 

<?php

class AuthController extends AuthControllerCore

{

 

.......

 

?>

 

same as there but now i put this in to any of the functions

 

 

echo "<script>

 

alert('Hello! I am an alert box!!');

 

</script>";

 

but nuthign happens

 

actually i ant to over ride

 

Protected function processSubmitAccount()

 

it happens exactly nicely in 1.4 version but 1520 it is not happening at all???

 

if i put this in orginal file

 

public function setMedia()

{

echo "<script>

 

alert('Hello! I am an alert box!!');

 

</script>";

parent::setMedia();

$this->addCSS(_THEME_CSS_DIR_.'authentication.css');

$this->addJqueryPlugin('typewatch');

$this->addJS(_THEME_JS_DIR_.'tools/statesManagement.js');

}

 

it works and if in over ride file then it dosent work so override not happening why???

Edited by boxybh28 (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

ok finally manage to start the over rides . some problem with the cache of prestashop getting stuck

on my new problem is that it is not redirecting properly

 

if i give

header('Location: http://www.example.com/');

 

it works

it dosent work if i give any of the following

 

header('Location: http://www.example.com/');
header('Location: '_PS_BASE_URL_.__PS_BASE_URI__.'registered.php');

 

 

and tried many more

tried redirect link

actually it is supposed to take to another page after registering the override code is here

<?php
class AuthController extends AuthControllerCore
{



protected function processSubmitAccount()
{

	Hook::exec('actionBeforeSubmitAccount');
 $this->create_account = true;
 if (Tools::isSubmit('submitAccount'))
  $this->context->smarty->assign('email_create', 1);
 // New Guest customer
 if (!Tools::getValue('is_new_customer', 1) && !Configuration::get('PS_GUEST_CHECKOUT_ENABLED'))
  $this->errors[] = Tools::displayError('You cannot create a guest account.');
 if (!Tools::getValue('is_new_customer', 1))
  $_POST['passwd'] = md5(time()._COOKIE_KEY_);
 if (isset($_POST['guest_email']) && $_POST['guest_email'])
  $_POST['email'] = $_POST['guest_email'];
 // Checked the user address in case he changed his email address
 if (Validate::isEmail($email = Tools::getValue('email')) && !empty($email))
  if (Customer::customerExists($email))
$this->errors[] = Tools::displayError('An account is already registered with this e-ccmail.', false);
 // Preparing customer
 $customer = new Customer();
 $_POST['lastname'] = Tools::getValue('customer_lastname');
 $_POST['firstname'] = Tools::getValue('customer_firstname');

 if (Configuration::get('PS_ONE_PHONE_AT_LEAST') && !Tools::getValue('phone') && !Tools::getValue('phone_mobile') &&
(Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || Configuration::get('PS_GUEST_CHECKOUT_ENABLED')))
  $this->errors[] = Tools::displayError('You must register at least one phone number');

 $this->errors = array_unique(array_merge($this->errors, $customer->validateController()));
 // Check the requires fields which are settings in the BO
 $this->errors = array_merge($this->errors, $customer->validateFieldsRequiredDatabase());
 if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount'))
 {

  if (!count($this->errors))
  {
if (Tools::isSubmit('newsletter'))
 $this->processCustomerNewsletter($customer);
$customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']);

$customer->active = 1;
			 // New Guest customer
if (Tools::isSubmit('is_new_customer'))
 $customer->is_guest = !Tools::getValue('is_new_customer', 1);
else
 $customer->is_guest = 0;

if (!count($this->errors))
 if (!$customer->add())
  $this->errors[] = Tools::displayError('An error occurred while creating your account.');
 else
 {
  if (!$customer->is_guest)
   if (!$this->sendConfirmationMail($customer))
	$this->errors[] = Tools::displayError('Cannot send e-mail');
  $this->updateContext($customer);
  $this->context->cart->update();
  Hook::exec('actionCustomerAccountAdd', array(
	'_POST' => $_POST,
	'newCustomer' => $customer
   ));

						header('Location: '._PS_BASE_URL_.__PS_BASE_URI__.'aaaa/aaaa.php');
  //header('Location: http://www.example.com/');
					//header('Location: '_PS_BASE_URL_.__PS_BASE_URI__.'aaaa.php');

					//exit (_PS_BASE_URL_.__PS_BASE_URI__.'aaaa.php');

 }
  }
 }





 }



}

even Tools::redirect doesn't work. it lands back to the myaccount page, but if given redirect to if $customer->active = 0; then only these work www.google.come or www.example.com . it works??? ]

if i keep $customer->active = 1; then all work

any help?

Edited by boxybh28 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...