/** * Unit-test for Password::check * * @covers Veles\Auth\Password::check * @dataProvider checkProvider * @see Veles\Auth\Password::check * * @param $user * @param $password * @param $expected */ public function testCheck($user, $password, $expected) { $result = Password::check($user, $password); $msg = 'Wrong result type: ' . gettype($result); $this->assertInternalType('bool', $result, $msg); $txt_result = $result ? 'true' : 'false'; $msg = "Password::check \"{$password}\" has wrong result: {$txt_result}"; $this->assertSame($expected, $result, $msg); }
/** * User authentication by login form * * @return bool */ public function identify() { $filter = new DbFilter(); $where = 'email = \'' . $this->getLogin() . '\' AND "group" & ' . UsrGroup::DELETED . ' = 0 '; $filter->setWhere($where); if (!$this->findUser($filter)) { return false; } $this->delCookie(); if (!Password::check($this->getUser(), $this->getPassword())) { $this->errors |= self::ERR_WRONG_PASSWORD; return false; } $this->setCookie(['expired' => strtotime('+365 days')]); return true; }