How do I avoid rehashing a password field on update?
Hi!
I have an action file that creates a record with a hashed password:
<cfquery datasource="#ds#">
INSERT INTO tbl_User(Email, RoleID, password)
VALUES ('#email#', '#session.UserRoleID#', '#hash(form.Password,'SHA')#');
</cfquery>The password field in my new database record begins with "2879EA..."
The next file in my registration process invokes a CFC method:
<cfinvoke component="users"
method="get"
Userid="#session.UserID#"
returnvariable="userData">
</cfinvoke>It sets the password variable using that query's results:
<cfset password=Trim(userData.password)>And populates the update form:
<tr><td>Password:</td>
<td><cfinput type="password" name="Password" size="17" maxlength="50" required="Yes" value="#hash(Password,'SHA')# " message="You must enter a password." style="font-size: 83%;"> </td></tr> When I click the update button, my form redisplays with all the updated fields, but the password field in the database now begins with "1490BE..."
This means I'm hashing my already hashed password. How do I avoid doing this?
Thanks,
John
