Skip to content

Commit

Permalink
enh(dav): TermsNotSignedException
Browse files Browse the repository at this point in the history
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Dec 5, 2024
1 parent 81dc9f2 commit e70b540
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Dav/CheckPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

use Sabre\DAV\Server;
use Sabre\DAV\ServerPlugin;
use Sabre\DAV\Exception\Forbidden;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;

use OCA\TermsOfService\AppInfo\Application;
use OCA\TermsOfService\Checker;
use OCA\TermsOfService\TermsNotSignedException;


class CheckPlugin extends ServerPlugin {
/** @var Server */
Expand Down Expand Up @@ -53,7 +54,7 @@ public function checkToS(RequestInterface $request, ResponseInterface $response)
// we instantiate the checker here to make sure sabre auth backend was triggered
$checker = \OCP\Server::get(Checker::class);
if (!$checker->currentUserHasSigned()) {
throw new Forbidden($checker->getForbiddenMessage());
throw new TermsNotSignedException($checker->getForbiddenMessage());
}
return true;
}
Expand Down
15 changes: 15 additions & 0 deletions lib/TermsNotSignedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\TermsOfService;

use Sabre\DAV\Exception\Forbidden;

class TermsNotSignedException extends Forbidden {
}

0 comments on commit e70b540

Please sign in to comment.