Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

checkHash return false

I've got following code to log into site

    if ($this->request->isPost()) {

        $username = $this->request->getPost('username');
        $password = $this->request->getPost('password');

        $user = Users::findFirst(array(
            "(username = :username:)",
            'bind' => array('username' => $username)
        ));

        if(!$user){
            $this->flash->error('User with username ' . $username . ' not exist.');
            return $this->forward('session/index');
        }

        if(!$this->security->checkHash($password, $user->password)){
            $this->flash->error('Wrong password');
            return $this->forward('session/index');
        }

        $this->_registerSession($user);
        $this->flash->success('Welcome ' . $user->fullname);
        return $this->forward('dashboard/index');
      }

I can connect to db because when I try $user->password I;m getting correct hashed password from db and also $password return correct password that user have put into input.

Why it return false on checkHash?

Have you hashed and stored the password with security->hash($rawPassword) and the same setup for the security service?

https://docs.phalconphp.com/en/latest/reference/security.html

Yes, I've done that.

Have you hashed and stored the password with security->hash($rawPassword) and the same setup for the security service?

https://docs.phalconphp.com/en/latest/reference/security.html



2.6k
Accepted
answer

I've fixed issue. Prlem was wth db where varchar vas seto to 55 long not 60