Merge pull request #5367 from nextcloud/better-share-error
Better error message on invalid sharing link
This commit is contained in:
commit
101d1c0f81
|
@ -1090,7 +1090,7 @@ class Manager implements IManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($share === null) {
|
if ($share === null) {
|
||||||
throw new ShareNotFound();
|
throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->checkExpireDate($share);
|
$this->checkExpireDate($share);
|
||||||
|
@ -1110,7 +1110,7 @@ class Manager implements IManager {
|
||||||
if ($share->getExpirationDate() !== null &&
|
if ($share->getExpirationDate() !== null &&
|
||||||
$share->getExpirationDate() <= new \DateTime()) {
|
$share->getExpirationDate() <= new \DateTime()) {
|
||||||
$this->deleteShare($share);
|
$this->deleteShare($share);
|
||||||
throw new ShareNotFound();
|
throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2142,6 +2142,7 @@ class ManagerTest extends \Test\TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \OCP\Share\Exceptions\ShareNotFound
|
* @expectedException \OCP\Share\Exceptions\ShareNotFound
|
||||||
|
* @expectedExceptionMessage The requested share does not exist anymore
|
||||||
*/
|
*/
|
||||||
public function testGetShareByTokenExpired() {
|
public function testGetShareByTokenExpired() {
|
||||||
$this->config
|
$this->config
|
||||||
|
@ -2150,6 +2151,10 @@ class ManagerTest extends \Test\TestCase {
|
||||||
->with('core', 'shareapi_allow_links', 'yes')
|
->with('core', 'shareapi_allow_links', 'yes')
|
||||||
->willReturn('yes');
|
->willReturn('yes');
|
||||||
|
|
||||||
|
$this->l->expects($this->once())
|
||||||
|
->method('t')
|
||||||
|
->willReturnArgument(0);
|
||||||
|
|
||||||
$manager = $this->createManagerMock()
|
$manager = $this->createManagerMock()
|
||||||
->setMethods(['deleteShare'])
|
->setMethods(['deleteShare'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
Loading…
Reference in New Issue