From 1420cd5a7e19a7c881c98d515b28d3a1e775e6b2 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Thu, 14 Nov 2019 00:55:22 -0100 Subject: [PATCH 1/2] adding share type circles Signed-off-by: Maxence Lange --- apps/dav/lib/Connector/PublicAuth.php | 5 ++++- lib/private/Share20/Manager.php | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/Connector/PublicAuth.php b/apps/dav/lib/Connector/PublicAuth.php index 8d29704c97069..6b8341f70470e 100644 --- a/apps/dav/lib/Connector/PublicAuth.php +++ b/apps/dav/lib/Connector/PublicAuth.php @@ -97,7 +97,10 @@ protected function validateUserPass($username, $password) { // check if the share is password protected if ($share->getPassword() !== null) { - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK || $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { + + if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK + || $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL + || $share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) { if ($this->shareManager->checkPassword($share, $password)) { return true; } else if ($this->session->exists('public_link_authenticated') diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 33a6553172cf5..8128e4f0ba44c 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1330,7 +1330,8 @@ protected function checkExpireDate($share) { */ public function checkPassword(\OCP\Share\IShare $share, $password) { $passwordProtected = $share->getShareType() !== \OCP\Share::SHARE_TYPE_LINK - || $share->getShareType() !== \OCP\Share::SHARE_TYPE_EMAIL; + || $share->getShareType() !== \OCP\Share::SHARE_TYPE_EMAIL + || $share->getShareType() !== \OCP\Share::SHARE_TYPE_CIRCLE; if (!$passwordProtected) { //TODO maybe exception? return false; From d6a276c57d97106a9ca137c1bfaad23fcae7eccc Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Wed, 4 Dec 2019 22:11:18 -0100 Subject: [PATCH 2/2] using IShare:: Signed-off-by: Maxence Lange --- apps/dav/lib/Connector/PublicAuth.php | 9 +++++---- lib/private/Share20/Manager.php | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/dav/lib/Connector/PublicAuth.php b/apps/dav/lib/Connector/PublicAuth.php index 6b8341f70470e..149ed62bfa05c 100644 --- a/apps/dav/lib/Connector/PublicAuth.php +++ b/apps/dav/lib/Connector/PublicAuth.php @@ -34,6 +34,7 @@ use OCP\ISession; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; +use OCP\Share\IShare; use Sabre\DAV\Auth\Backend\AbstractBasic; /** @@ -98,9 +99,9 @@ protected function validateUserPass($username, $password) { // check if the share is password protected if ($share->getPassword() !== null) { - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK - || $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL - || $share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) { + if ($share->getShareType() === IShare::TYPE_LINK + || $share->getShareType() === IShare::TYPE_EMAIL + || $share->getShareType() === IShare::TYPE_CIRCLE) { if ($this->shareManager->checkPassword($share, $password)) { return true; } else if ($this->session->exists('public_link_authenticated') @@ -115,7 +116,7 @@ protected function validateUserPass($username, $password) { } return false; } - } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) { + } else if ($share->getShareType() === IShare::TYPE_REMOTE) { return true; } else { return false; diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 8128e4f0ba44c..c902f2a31e1ea 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1329,9 +1329,9 @@ protected function checkExpireDate($share) { * @return bool */ public function checkPassword(\OCP\Share\IShare $share, $password) { - $passwordProtected = $share->getShareType() !== \OCP\Share::SHARE_TYPE_LINK - || $share->getShareType() !== \OCP\Share::SHARE_TYPE_EMAIL - || $share->getShareType() !== \OCP\Share::SHARE_TYPE_CIRCLE; + $passwordProtected = $share->getShareType() !== IShare::TYPE_LINK + || $share->getShareType() !== IShare::TYPE_EMAIL + || $share->getShareType() !== IShare::TYPE_CIRCLE; if (!$passwordProtected) { //TODO maybe exception? return false;