user1587985
user1587985

Reputation: 685

Codeigniter tank auth check user entered password

I'm using Tank Auth for my website.

I've searched for a function that would check if user has entered a valid password, when he tries to update his profile.

I don't understand how to hash password from user input that would match one in database.

Here's my controllers code:

            $password = $this->input->post('password');
            $hasher = new PasswordHash(
                $this->config->item('phpass_hash_strength', 'tank_auth'),
                $this->config->item('phpass_hash_portable', 'tank_auth')
            );
            $hashed_password = $hasher->HashPassword($password);

$hashed_password gives me different hash each time

I dont think that i should enable phpass_hash_portable

Any advices?

Upvotes: 0

Views: 759

Answers (2)

Ankur Agarwal
Ankur Agarwal

Reputation: 31

You can check your password by using this function:

$hasher->CheckPassword(password which has to be checked,password from database).

instead of encrypting yourself.

Note: password which has to be checked => is raw data password from database => password from database.

Upvotes: 0

Ankur Agarwal
Ankur Agarwal

Reputation: 31

You need to use the CheckPassword module of the Tank Auth instead of hashing it by using the PasswordHash of the phpass.

Upvotes: 2

Related Questions