/** * Checks the user credentials * * @param array $credentials * @throws Exception * @return boolean */ public function check($credentials) { $user = PhadAdministrators::findFirstByName(strtolower($credentials['name'])); if ($user == false) { throw new Exception('Wrong email/password combination'); } if (!$this->security->checkHash($credentials['password'], $user->password)) { throw new Exception('Wrong email/password combination'); } $this->setIdentity($user); }
public function changePassAction() { $params = $this->dispatcher->getParams(); if (!isset($params['params'][0], $params['params'][1])) { echo "You did not specify the name or password.\n"; return; } $name = $params['params'][0]; $pass = $params['params'][1]; try { $administrator = PhadAdministrators::findFirstByName($name); $administrator->password = $this->security->hash($pass); $administrator->save(); } catch (Exception $e) { $massage = $e->getMessage(); echo "{$massage}\n"; return; } echo "The password was changed successfully.\n"; }