I'm developing an API using CodeIgniter 4 and OAuth2. I have an existing database that I need to use but the web app is made from CodeIgniter 3 and I used Ion Auth for authentication. How can I compare the given password by the user to the equivalent password in the database using Ion Auth's verify password function? Or is there a way I can compare passwords without Ion Auth at all?
The code snippet I need to change in OAuth2 located in OAuth2\Storage\Pdo.php
:
protected function checkPassword($user, $password)
{
return $user['password'] == $this->hashPassword($password);
}
// use a secure hashing algorithm when storing passwords. Override this for your application
protected function hashPassword($password)
{
return sha1($password);
}
I'm not sure how I can do this. Worse case scenario, I'll switch back to CI3 and do another API.
Any help is highly appreciated.
I replaced the
checkPassword
function with this:That's it!