public function tryLoginUser(UserCredentials $toLogin) { $registered = $this->userDAL->getUserByName($toLogin->getUsername()); $tempPassword = $this->tempDAL->getTempPassword($toLogin->getUsername()); $loginByPostCredentials = password_verify($toLogin->getPassword(), $registered->getPassword()); $loginByCookies = $tempPassword != "" && $tempPassword === $toLogin->getCookiePassword(); if (!$loginByPostCredentials && !$loginByCookies) { throw new \WrongCredentialsException("Wrong credentials"); } $this->loginUser($toLogin); }
/** * Registrates the current user in the database table * @param active user name * @return boolean */ public function registerName(UserCredentials $userCredentials) { $name = $userCredentials->getUsername(); $password = $userCredentials->getPassword(); $this->dal->insertUser($name, $password); return true; }
private function saveUser(UserCredentials $credentials) { $this->DAL->saveUserCredentials($credentials->getUsername(), $credentials->getPassword()); }