mirror of
https://github.com/nextcloud/server.git
synced 2026-06-14 03:02:01 -04:00
Merge pull request #49835 from nextcloud/backport/49822/stable28
[stable28] fix(files_sharing): Fix error messages from password policy
This commit is contained in:
commit
cbbedace81
3 changed files with 9 additions and 7 deletions
|
|
@ -69,6 +69,7 @@ use OCP\Files\InvalidPathException;
|
|||
use OCP\Files\IRootFolder;
|
||||
use OCP\Files\Node;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\HintException;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDateTimeZone;
|
||||
use OCP\IGroupManager;
|
||||
|
|
@ -80,7 +81,6 @@ use OCP\IUserManager;
|
|||
use OCP\Lock\ILockingProvider;
|
||||
use OCP\Lock\LockedException;
|
||||
use OCP\Server;
|
||||
use OCP\Share\Exceptions\GenericShareException;
|
||||
use OCP\Share\Exceptions\ShareNotFound;
|
||||
use OCP\Share\IManager;
|
||||
use OCP\Share\IShare;
|
||||
|
|
@ -825,7 +825,7 @@ class ShareAPIController extends OCSController {
|
|||
|
||||
try {
|
||||
$share = $this->shareManager->createShare($share);
|
||||
} catch (GenericShareException $e) {
|
||||
} catch (HintException $e) {
|
||||
$code = $e->getCode() === 0 ? 403 : $e->getCode();
|
||||
throw new OCSException($e->getHint(), $code);
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -1360,7 +1360,7 @@ class ShareAPIController extends OCSController {
|
|||
|
||||
try {
|
||||
$share = $this->shareManager->updateShare($share);
|
||||
} catch (GenericShareException $e) {
|
||||
} catch (HintException $e) {
|
||||
$code = $e->getCode() === 0 ? 403 : $e->getCode();
|
||||
throw new OCSException($e->getHint(), (int)$code);
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -1452,7 +1452,7 @@ class ShareAPIController extends OCSController {
|
|||
|
||||
try {
|
||||
$this->shareManager->acceptShare($share, $this->currentUser);
|
||||
} catch (GenericShareException $e) {
|
||||
} catch (HintException $e) {
|
||||
$code = $e->getCode() === 0 ? 403 : $e->getCode();
|
||||
throw new OCSException($e->getHint(), (int)$code);
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class Manager implements IManager {
|
|||
* Verify if a password meets all requirements
|
||||
*
|
||||
* @param string $password
|
||||
* @throws \Exception
|
||||
* @throws HintException
|
||||
*/
|
||||
protected function verifyPassword($password) {
|
||||
if ($password === null) {
|
||||
|
|
@ -145,7 +145,8 @@ class Manager implements IManager {
|
|||
try {
|
||||
$this->dispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password));
|
||||
} catch (HintException $e) {
|
||||
throw new \Exception($e->getHint());
|
||||
/* Wrap in a 400 bad request error */
|
||||
throw new HintException($e->getMessage(), $e->getHint(), 400, $e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -896,6 +897,7 @@ class Manager implements IManager {
|
|||
* @param IShare $share
|
||||
* @return IShare The share object
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws HintException
|
||||
*/
|
||||
public function updateShare(IShare $share) {
|
||||
$expirationDateUpdated = false;
|
||||
|
|
|
|||
|
|
@ -608,7 +608,7 @@ class ManagerTest extends \Test\TestCase {
|
|||
$this->assertInstanceOf(ValidatePasswordPolicyEvent::class, $event);
|
||||
/** @var ValidatePasswordPolicyEvent $event */
|
||||
$this->assertSame('password', $event->getPassword());
|
||||
throw new HintException('message', 'password not accepted');
|
||||
throw new HintException('password not accepted');
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue