Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 339305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:30:38+00:00 2026-05-12T10:30:38+00:00

Greetings, I am setting up a pretty standard registration form with password field. The

  • 0

Greetings,

I am setting up a pretty standard registration form with password field.

The problem is, after a failed submission (due to empty field, incorrect format etc), the controller reloads the registration page, but with the password field containing the hashed value of the previously entered password. How do I make it empty after each failed submission?

View:

echo $form->password('Vendor.password', array('class' => 'text-input'));

Controller:

Security::setHash('sha1');
$this->Auth->sessionKey = 'Member'; 
$this->Auth->fields = array(
    'username' => 'email',
    'password' => 'password'
);

Help is very much appreciated, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:30:39+00:00Added an answer on May 12, 2026 at 10:30 am

    You may run into another problem down the road with cakePHP password validation.

    The problem is that cake hashes passwords first, then does validation, which can cause the input to fail even if it is valid according to your rules. This is why the password is returned to the input field hashed instead of normal.


    to fix this, instead of using the special field name ‘password’, use a different name like ‘tmp_pass’. This way, cakePHP Auth won’t automatically hash the field.

    Here’s a sample form

    echo $form->create('Vendor', array('action' => 'register'));
    echo $form->input('email');
    echo $form->input( 'tmp_pass', array( 'label' => 'Password','type'=>'password' ));
    echo $form->end('Register');
    

    In your Vendor model, don’t assign validation rules to ‘password’ instead assign these rules to ‘tmp_pass’, for example

    var $validate = array('email' => 'email', 'password' => ... password rules... );
    

    becomes

    var $validate = array('email' => 'email', 'tmp_pass' => ... password rules... );
    

    Finally, in your Vendor model, implement beforeSave().

    First, see if the data validates (‘tmp_pass’ will be validated against your rules).

    If successful, manually hash tmp_pass and put it in $this->data[‘Vendor’][‘password’] then return true. If unsuccessful, return false.

    function beforeSave() {
        if($this->validates()){
            $this->data['Vendor']['password'] = sha1(Configure::read('Security.salt') . $this->data['User']['tmp_pass']);
            return true;
        }
        else
            return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, I have a problem which would seem to involve some kind of z-index
Greetings all. I'm setting up a cron job to execute a bash script, and
Greetings SO, I have a weird problem that I don't seem to be able
Greetings. I'm having a weird problem with jQuery on my website. I'm trying to
Greetings, I'm having problem invoking a richTextBox from a worker thread in C#. I'm
Greetings good people of the internet:) I have a string value 1,5 which after
Greetings Overflowers, Is there an SQL DBMS that allows me to create an indexed
Greetings everyone and thank you for checking out my post. I am trying to
Greetings! I have a Repeater control that's using an XmlDataSource control. <asp:FormView id=myFormView runat=server
Greetings, I am trying to learn pointers in C, I simply want my addtwo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.