Jump to content

How to compare password


nikola
 Share

Recommended Posts

I have a front end login form and I would like to compare password that user inputs with the password in the system (database).

How can I do it because password in database is hashed and salted so I can throw them an error if they put in the wrong password.

Link to comment
Share on other sites

You can do this:

if($user->pass->matches("yourpassword")){
  // correct
}

But normally you just login and if it fails you know it's wrong.

if($session->login("nam","password")){
   // logged in
}
  • Like 3
Link to comment
Share on other sites

if($user->pass->matches
if($session->login

If I go to the api cheatsheet I see $user->pass and $session-> but I can't find anything about the parts "->matches" after pass, and "->login" after $session. I am sure that I am overlooking something that must be obvious but where can I find more about this ?

Link to comment
Share on other sites

http://processwire.com/api/cheatsheet/?filter=login&advanced

The InputfieldPassword::matches isn't in there since it was also not in API documentation and also belongs to the InputfieldPassword module which is not part of the cheatsheet. Not every method there is is on the cheatsheet, lots of more advanced stuff is left out. Soon we gonna add new stuff that's added recently in 2.3.

  • Like 2
Link to comment
Share on other sites

The InputfieldPassword::matches isn't in there since it was also not in API documentation and also belongs to the InputfieldPassword module which is not part of the cheatsheet.

The matches() function has actually been moved to be part of the Password value itself, so this is one thing I will add to the 2.3 API docs. 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...