Checking bcrypt passwords always fails. Phalcon php

I have a little problem checking passwords using phalcon php. I have: Log in to the script where I check the password

$username = $this->request->getPost('username', 'string');
            $password = $this->request->getPost('password', 'string');
            $conditions = "Username = :username:";
            $parameters = array (
                "username" => $username
            );

            $user = Users::findFirst(array($conditions, 'bind' => $parameters));
            //check if user exists
            if (count($user) > 0 && $user !== false) {

                if ($this->security->checkHash($password, $user->Password))  //always fails {
                    //login 
                    $this->session->set('username', $user->Password);
                    $this->response->redirect('index');

                }

In my registration I have:

$name = $this->request->getPost('name', 'string');
            $lastName = $this->request->getPost('lastName', 'string');
            $username = $this->request->getPost('username', 'string');
            $password = $this->request->getPost('password', 'string');
            $email = $this->request->getPost('email', 'email');

            $user = new Users(); //model
            $user->Name = $name;
            $user->LastName = $lastName;
            $user->Username = $username;
            $user->Password = $this->security->hash($password);
            $user->Email = $email;
            if ($user->save() == true) {
                //registered
            } else {
                //error
            }

It seems like I'm doing anything in the documentation , but it doesn't seem to work. Can anyone help me please.

+4
source share
1 answer

jt26, $this->security->hash('jt26'). , , register/login. jt26 , $this->security->hash('jt26'), .

. ?

, , . . . ( ), . Bcrypt , , .

0

Source: https://habr.com/ru/post/1539099/


All Articles