Jump to content

[SOLVED] Password Confirm


Recommended Posts

When a customer tries to create a new account there is no field for confirming the password choice.

I am sure I must be missing something in configuring my installation.

Can someone suggest how I can make sure that the password is confirmed on creation of new accounts?

Thanks

Link to comment
Share on other sites

Yes a must have. This forum makes you confirm your password when you register but Prestashop does not. Since the online demo does exactly the same thing as my installation I am assumeing this is an oversight?

Next question then is when will this be fixed?

Link to comment
Share on other sites

  • 2 months later...

Hello,

I made a little script for this feature. Please test it and say me if it works on your project.



{l s='Confirm password'}
   <input type="password" class="text" name="passwd_confirm" id="passwd_confirm" />
*

[removed]
   $(function(){ldelim}
       $("#passwd_confirm").parents("form").submit(function(){ldelim}
           if ($('#passwd').attr('value') == $('#passwd_confirm').attr('value'))
               return true;
           alert("{l s='Yours both passwords filled in do not match.'}");
           return false;
       {rdelim});
   {rdelim});
[removed]

  • Like 1
Link to comment
Share on other sites

It works but i have to guess what you are say about remove blank space....

I think it is better for the next people to have the code correct.... In Themes/Prestashop/Autenthication.tpl insert in line 118 the following code:


{l s='Confirm password'}
   <input type="password" class="text" name="passwd_confirm" id="passwd_confirm" />
*

[removed] 
   $(function(){ldelim}
       $("#passwd_confirm").parents("form").submit(function(){ldelim}
           if ($('#passwd').attr('value') == $('#passwd_confirm').attr('value'))
               return true;
           alert("{l s='Yours both passwords filled in do not match.'}");
           return false;
       {rdelim});
   {rdelim});
[removed]



Many thanks to you for this :-)

Link to comment
Share on other sites

You can avoid this happening by entering <script type="text/javascript"> and </script> like this:



{l s='Confirm password'}
   <input type="password" class="text" name="passwd_confirm" id="passwd_confirm" />
*

<script type="text/javascript">
$(function(){ldelim}
       $("#passwd_confirm").parents("form").submit(function(){ldelim}
           if ($('#passwd').attr('value') == $('#passwd_confirm').attr('value'))
               return true;
           alert("{l s='Yours both passwords filled in do not match.'}");
           return false;
       {rdelim});
   {rdelim});
</script>

  • Like 1
Link to comment
Share on other sites

  • 7 months later...

Hi,

Are you guys sure the code works.

I tested the solution and ran into two problems.

1) Dreamweaver tells me that

$("passwd_confirm").parents("form").submit(function(){ldelim});

has a syntax error.

2) If I ignore number 1)

The input field for "password confirmation" will be there during registration but even if the passwords don't match the registration process continues.

Link to comment
Share on other sites

Hi Iphan,

1) If think Dreamweaver don't understand javascript code with jQuery syntax. And your syntax is not good, missing "{rdelim}" at the end, before ");". Please copy/paste correctly code of this thread.
2) I don't know why, but if your javascript is not good certainly it don't works.

Have you got javascript error in your browser ?

Link to comment
Share on other sites

Hi Joel,

Thanks for replying. I did copy/paste the exact code that you posted. Like I said before, it will run but there it does not check if the passwords match. I have tested on 3 different browsers. The code does not stop me from registering even if the passwords don't match.

I linked a screenshot below so you can see what I mean.

http://www.mediafire.com/imgbnc.php/5b6e3663121199150f31ea5e92e0758d6g.jpg

Link to comment
Share on other sites

You can avoid this happening by entering <script type="text/javascript"> and </script> like this:



{l s='Confirm password'}
   <input type="password" class="text" name="passwd_confirm" id="passwd_confirm" />
*

<script type="text/javascript">
$(function(){ldelim}
       $("#passwd_confirm").parents("form").submit(function(){ldelim}
           if ($('#passwd').attr('value') == $('#passwd_confirm').attr('value'))
               return true;
           alert("{l s='Yours both passwords filled in do not match.'}");
           return false;
       {rdelim});
   {rdelim});
</script>



Million Tnx :D

It'working well in firefox,safari , actually i could to test on these browser
Link to comment
Share on other sites

  • 3 months later...

Joël,

Thanks for your reply. I have now tested it in Firefox and Chrome and it doesn't work in either of those as well. I also have the problem that when I removed the code the page will now not automatically redirect to the Welcome page when you register. I suspect the problem is not entirely in the Authentication.tpl file. If you have any clues as to where I should look to try to solve this I'd be very grateful.

Regards
Tony

Link to comment
Share on other sites

Sorry I didn't understand very well english (i'm just a french man)

I have now tested it in Firefox and Chrome and it doesn't work in either of those as well. I also have the problem that when I removed the code the page will now not automatically redirect to the Welcome page when you register. I suspect the problem is not entirely in the Authentication.tpl file. If you have any clues as to where I should look to try to solve this I'd be very grateful.

I don't believe normally PrestaShop redirect a new subscriber to homepage but to last page visited or customer account page.
Do you test this code on default theme ?
Link to comment
Share on other sites

Le probleme est que apres enregister, le nouveaux utilisateur reste sur le page d'inscription au lieu d'aller au page 'Welcome to your account'. S'il vous plait, pouvez-vous regarder www.lynseydepaul.com/musicstore de pres, et essayer d'enregistrer pour voir le probleme.

(I can't speak French but my daughter is learning it, hope this is ok.)

Regards

Tony

Link to comment
Share on other sites

I've fixed it. The problem is that the "Bloc My Account" module was installed, so there are two "passwd" fields. Since the one in the "My Account" block is declared first, the code was comparing the password of it to the "Confirm Password" field.

I fixed it by changing:

if ($('#passwd').attr('value') == $('#passwd_confirm').attr('value'))



to:

if ($('#center_column #passwd').attr('value') == $('#passwd_confirm').attr('value'))



so that the center column passwd is selected instead of the "My Account" block passwd.

Link to comment
Share on other sites

  • 4 weeks later...

Anybody using the One Page Checkout module with this mod??

This mod seems like a must have and a very standard one at that...

This works for the log in/authetication/sign up page... but the OPC module gives guest accounts/checkouts the option to sign up for a "real" account by checking a box at the end which then displays a (1) password box... I am interested in knowing if this option could be modded to work with the code/script from this thread.

Any help is appreciated!

Link to comment
Share on other sites

You should put the code here after the password field on line [spam-filter]96 of authentication.tpl (in PrestaShop v1.3.2):



{l s='Password'}
   <input type="password" class="text" name="passwd" id="passwd" />
*
{l s='(5 characters min.)'}



thanks rocky, so i put the code in the little link thing you made saying 'code' but where does the code you pasted below that go?

thanks
Link to comment
Share on other sites

  • 6 months later...
  • 3 months later...
  • 3 weeks later...

for prestashop 1.4.3 ( and above i think):

 

go to

themes/yourtheme/authentication.tpl

find:

<p class="required password">
  <label for="passwd">{l s='Password'}</label>
  <input type="password" name="passwd" id="passwd" />
  <sup>*</sup>
  <span class="form_info">{l s='(5 characters min.)'}</span>
 </p>

right after this insert:

   <p class="required password">
		    <label for="passwd_confirm">{l s='Confirm password'}</label>
		    <input type="password" class="text" name="passwd_confirm" id="passwd_confirm" />
		    <sup>*</sup>
	    </p>

 

2º go to:

/controllers/AuthController.php

 

find this:

$_POST['firstname'] = $_POST['customer_firstname']

 

below insert this:

if (Tools::getValue('passwd') != Tools::getValue('passwd_confirm'))
$this->errors[] = Tools::displayError('Passwords do not match');

 

its done , dont forget to backup ypu files before doing this changes

  • Like 3
Link to comment
Share on other sites

  • 3 months later...

Thank you friends! thank you rocky.

 

Work fine!

 

Gracias Francisco

 

 

for prestashop 1.4.3 ( and above i think):

 

go to

themes/yourtheme/authentication.tpl

find:

<p class="required password">
  <label for="passwd">{l s='Password'}</label>
  <input type="password" name="passwd" id="passwd" />
  <sup>*</sup>
  <span class="form_info">{l s='(5 characters min.)'}</span>
 </p>

right after this insert:

   <p class="required password">
			<label for="passwd_confirm">{l s='Confirm password'}</label>
			<input type="password" class="text" name="passwd_confirm" id="passwd_confirm" />
			<sup>*</sup>
		</p>

 

2º go to:

/controllers/AuthController.php

 

find this:

$_POST['firstname'] = $_POST['customer_firstname']

 

below insert this:

if (Tools::getValue('passwd') != Tools::getValue('passwd_confirm'))
$this->errors[] = Tools::displayError('Passwords do not match');

 

its done , dont forget to backup ypu files before doing this changes

Link to comment
Share on other sites

  • 3 months later...
  • 6 months later...

Great thread!

Thanks to all, I solved this heavy point. It's quite incredible that by default PS hasn't both email and password confirmation and a URL confirmation by email to validate the email. :blink:

Anyway, here the mod for PS 1.5.0.17 (and up, I hope), for email and for password confirmation (for email validation I'm still searching for :( ). In BO will appears fields for translating new fields in the FO auth page.

It seems to works very fine for me, but please test it!

 

In /themes/your-theme/authentication.tpl find:

 

 <p class="required text">
  <label for="email">{l s='E-mail'} <sup>*</sup></label>
  <input type="text" class="text" id="email" name="email" value="{if isset($smarty.post.email)}{$smarty.post.email}{/if}" />
 </p>

 

after insert:

 


<p class="required text">
<label for="email_confirm">{l s='Confirm e-mail'} <sup>*</sup></label>
<input type="text" class="text" name="email_confirm" id="email_confirm" />
</p>

 

find:

 

 <p class="required password">
  <label for="passwd">{l s='Password'} <sup>*</sup></label>
  <input type="password" class="text" name="passwd" id="passwd" />
  <span class="form_info">{l s='(5 characters min.)'}</span>
 </p>

 

after insert:

 

<p class="required password">
<label for="passwd_confirm">{l s='Confirm password'} <sup>*</sup></label>
<input type="password" class="text" name="passwd_confirm" id="passwd_confirm" />
</p>

 

 

In /controllers/front/AuthController.php find:

 

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

 

after insert:

 

 // Email confirmation
 if (Tools::getValue('email') != Tools::getValue('email_confirm'))
 $this->errors[] = Tools::displayError('Both email do not match');
 // Password confirmation
 if (Tools::getValue('passwd') != Tools::getValue('passwd_confirm'))
 $this->errors[] = Tools::displayError('Both passwords do not match');

 

 

That's all, it works fine!

Edited by viger (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Thank you Viger !

 

This works perfectly on version 1.4.8.2, tested on explorer, firefox and chrome.

 

I agree, this should be a default feature, or at least an option!

 

I would recommend however, rather than modifying the AddressController.php file directly, that it be copied into the override folder at /override/controllers and then edited.

 

If editing the file from within the override folder, remember to modify line 28 of the file

from

class AuthControllerCore extends FrontController

to

class AuthController extends FrontController

 

Thank you again Viger for your solution and to everyone for treating this topic!

  • Like 1
Link to comment
Share on other sites

I would recommend however, rather than modifying the AddressController.php file directly, that it be copied into the override folder at /override/controllers and then edited.

 

Yes, you're right, it's better indeed. Thanks to you too!

Link to comment
Share on other sites

  • 1 month later...

Hi,

 

I can't get this working,

 

The Theme I use is Theme318 and I've posted the code both here :

 

/home/protect1/themes/theme318/authentication.tpl

 

/home/protect1/public_html/themes/theme318/authentication.tpl

 

What am I doing wrong here as It doesn't seem to be working.

 

Thanks,

Link to comment
Share on other sites

  • 1 month later...

Hello

 

Just wanted to thank you for very interesting discussion and examples. It saved my time and works great with PrestaShop 1.4.9.0.

 

If somebody is unsure about 4.9 - password recovery works fine, errors are displayed correctly, user has to confirm password when updating profile too. Very nice solution!

Link to comment
Share on other sites

  • 2 months later...

Great thread!

Thanks to all, I solved this heavy point. It's quite incredible that by default PS hasn't both email and password confirmation and a URL confirmation by email to validate the email. :blink:

Anyway, here the mod for PS 1.5.0.17 (and up, I hope), for email and for password confirmation (for email validation I'm still searching for :( ). In BO will appears fields for translating new fields in the FO auth page.

It seems to works very fine for me, but please test it!

 

In /themes/your-theme/authentication.tpl find:

 

 <p class="required text">
  <label for="email">{l s='E-mail'} <sup>*</sup></label>
  <input type="text" class="text" id="email" name="email" value="{if isset($smarty.post.email)}{$smarty.post.email}{/if}" />
 </p>

 

after insert:

 


<p class="required text">
<label for="email_confirm">{l s='Confirm e-mail'} <sup>*</sup></label>
<input type="text" class="text" name="email_confirm" id="email_confirm" />
</p>

 

find:

 

 <p class="required password">
  <label for="passwd">{l s='Password'} <sup>*</sup></label>
  <input type="password" class="text" name="passwd" id="passwd" />
  <span class="form_info">{l s='(5 characters min.)'}</span>
 </p>

 

after insert:

 

<p class="required password">
<label for="passwd_confirm">{l s='Confirm password'} <sup>*</sup></label>
<input type="password" class="text" name="passwd_confirm" id="passwd_confirm" />
</p>

 

 

In /controllers/front/AuthController.php find:

 

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

 

after insert:

 

 // Email confirmation
 if (Tools::getValue('email') != Tools::getValue('email_confirm'))
 $this->errors[] = Tools::displayError('Both email do not match');
 // Password confirmation
 if (Tools::getValue('passwd') != Tools::getValue('passwd_confirm'))
 $this->errors[] = Tools::displayError('Both passwords do not match');

 

 

That's all, it works fine!

 

Hi viger,

 

Thanks a lot for the help with this. It works fine with normal checkout when you are logged in, but it doesn't work with guest checkout. It gives the errors

  1. Both email do not match
  2. Both passwords do not match

when pressing save after filling out the delivery address. Of course it is because the guest check-out does not have the password field and only 1 email field. Do you know how to change your code so it does not take into consideration when guest-checkout is used?

 

I am using 1.5.3.1 btw. Thanks a lot!

Link to comment
Share on other sites

Ok, I figured it out. If you want to make this work for guest checkout then you need to add this code:

 

  	 if (Tools::getValue('is_new_customer', 1) && Configuration::get('PS_GUEST_CHECKOUT_ENABLED'))
	{	
		// Email confirmation
		if (Tools::getValue('email') != Tools::getValue('email_confirm'))
		$this->errors[] = Tools::displayError('Both email do not match');
		// Password confirmation
		if (Tools::getValue('passwd') != Tools::getValue('passwd_confirm'))
		$this->errors[] = Tools::displayError('Both passwords do not match');
	}

 

instead of just:

 

 // Email confirmation
 if (Tools::getValue('email') != Tools::getValue('email_confirm'))
 $this->errors[] = Tools::displayError('Both email do not match');
 // Password confirmation
 if (Tools::getValue('passwd') != Tools::getValue('passwd_confirm'))
 $this->errors[] = Tools::displayError('Both passwords do not match');

 

This seem to work fine (not sure if it is the correct way to do it, so please test everything before goin live).

 

I hope this helps someone!

Link to comment
Share on other sites

  • 4 months later...
  • 2 years later...

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...