Jump to content

how to compare a password for changing password ?


adrianmak
 Share

Recommended Posts

I'm going to build a form for front-end user password changing.

There should be three input fields

current password

new password

confirm new password

I knew that, password stored in database is hashed.

How could I compare the input current password with the password stored in database ?

Link to comment
Share on other sites

@adrianmak

Firstly it takes alot of effort in terms of time bandwidth to document it all next to the documentation that is already provided in the source code. Then it is difficult to have the documentation that is not in the code to be in sync with the 'changing' documentation. Then keep in mind that most 'advanced' users will look in the source code to find 'documentation' or figure out what is going on right there anyway without searching decoupled documentation. Documentation should be written by 'advanced' users, on the other hand, those users are likely to use the source code to lookup methods and stuff, so they are not the 'real users' of that decoupled documentation. Then there is the NOT fun part of documenting. In a lively environment as ProcessWire, new methods are added other methods become deprecated. It's hard to keep track of all those. 

I think we all wish documentation stays in sync and is complete. On the other-hand, when looking in the source code of ProcessWire you will recognise the effort Ryan takes to document and comment. I have to say, that the documentation in the code base is good and keeps getting better over time.

  • Like 5
Link to comment
Share on other sites

  • 1 year later...

I am trying to do the same thing as adrianmak - had you figured out how to do this?

Do you need the 'current password' field? I think 'new password' and 'confirm new pass' should be enough if the user has access to this form. Or am I missing something?

You can use $user->pass->matches($inputPass) to check the input, but, to be clear, there is no PW function or similar that adds the same 'change password' thing that is in the admin profile edit?

Password is the same as any other input field? You can save a password from a form input simply with this?

...

$user->pass = $sanitizer->text($input->post->pass);

$user->save();

And then PW takes care of the hash stuff? The hash stuff is confusing... Or are there specific password checks or processes to take care of?

Edit:

I see there is an InputfieldPassword.module, probably part of the forms API that I still can't wrap my head around. I guess you should use that somehow?

Adding this, as a quick test, produces a server error:

Spoiler

<?php 

$field = $modules->get("InputfieldPassword");
$field->label = "Set new Password";
$field->attr("id+name","pass");
$field->required = 1;
$form->append($field);

?>

 

 

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
 Share

×
×
  • Create New...