/** * Validates the given password * * @param array|bool $linkItem * @param string $password * * @throws ServiceException */ private function checkPassword($linkItem, $password) { $newHash = ''; if ($this->hasher->verify($password, $linkItem['share_with'], $newHash)) { // Save item id in session for future requests $this->session->set('public_link_authenticated', $linkItem['id']); if (!empty($newHash)) { // For future use } } else { $this->logAndThrow("Wrong password", Http::STATUS_UNAUTHORIZED); } }
/** * Validates the given password * * @param array|bool $linkItem * @param string $password * * @throws CheckException */ private function checkPassword($linkItem, $password) { $newHash = ''; if ($this->hasher->verify($password, $linkItem['share_with'], $newHash)) { // Save item id in session for future requests $this->session->set('public_link_authenticated', $linkItem['id']); // @codeCoverageIgnoreStart if (!empty($newHash)) { // For future use } // @codeCoverageIgnoreEnd } else { throw new CheckException("Wrong password", Http::STATUS_UNAUTHORIZED); } }
/** * Verify the password of a public share * * @param IShare $share * @param string $password * @return bool */ public function checkPassword(IShare $share, $password) { if ($share->getShareType() !== \OCP\Share::SHARE_TYPE_LINK) { //TODO maybe exception? return false; } if ($password === null || $share->getPassword() === null) { return false; } $newHash = ''; if (!$this->hasher->verify($password, $share->getPassword(), $newHash)) { return false; } if (!empty($newHash)) { //TODO update hash! } return true; }
/** * Verify the password of a public share * * @param \OCP\Share\IShare $share * @param string $password * @return bool */ public function checkPassword(\OCP\Share\IShare $share, $password) { if ($share->getShareType() !== \OCP\Share::SHARE_TYPE_LINK) { //TODO maybe exception? return false; } if ($password === null || $share->getPassword() === null) { return false; } $newHash = ''; if (!$this->hasher->verify($password, $share->getPassword(), $newHash)) { return false; } if (!empty($newHash)) { $share->setPassword($newHash); $provider = $this->factory->getProviderForType($share->getShareType()); $provider->update($share); } return true; }