Unify settings middleware with others
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
ad0731a63c
commit
6e46df26a8
|
@ -114,7 +114,7 @@ class AuthSettingsController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoSubadminRequired
|
||||
* @NoSubAdminRequired
|
||||
* @PasswordConfirmationRequired
|
||||
*
|
||||
* @param string $name
|
||||
|
@ -183,7 +183,7 @@ class AuthSettingsController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoSubadminRequired
|
||||
* @NoSubAdminRequired
|
||||
*
|
||||
* @param int $id
|
||||
* @return array|JSONResponse
|
||||
|
@ -205,7 +205,7 @@ class AuthSettingsController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoSubadminRequired
|
||||
* @NoSubAdminRequired
|
||||
*
|
||||
* @param int $id
|
||||
* @param array $scope
|
||||
|
@ -278,7 +278,7 @@ class AuthSettingsController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoSubadminRequired
|
||||
* @NoSubAdminRequired
|
||||
* @PasswordConfirmationRequired
|
||||
*
|
||||
* @param int $id
|
||||
|
|
|
@ -85,7 +85,7 @@ class ChangePasswordController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoSubadminRequired
|
||||
* @NoSubAdminRequired
|
||||
* @BruteForceProtection(action=changePersonalPassword)
|
||||
*/
|
||||
public function changePersonalPassword(string $oldpassword = '', string $newpassword = null): JSONResponse {
|
||||
|
|
|
@ -67,7 +67,7 @@ class HelpController extends Controller {
|
|||
*
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @NoSubadminRequired
|
||||
* @NoSubAdminRequired
|
||||
*/
|
||||
public function help(string $mode = 'user'): TemplateResponse {
|
||||
$this->navigationManager->setActiveEntry('help');
|
||||
|
|
|
@ -61,7 +61,7 @@ class PersonalSettingsController extends Controller {
|
|||
*
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @NoSubadminRequired
|
||||
* @NoSubAdminRequired
|
||||
*/
|
||||
public function index($section) {
|
||||
return $this->getIndexResponse('personal', $section);
|
||||
|
|
|
@ -311,7 +311,7 @@ class UsersController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoSubadminRequired
|
||||
* @NoSubAdminRequired
|
||||
* @PasswordConfirmationRequired
|
||||
*
|
||||
* @param string $avatarScope
|
||||
|
@ -440,7 +440,7 @@ class UsersController extends Controller {
|
|||
* Set the mail address of a user
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoSubadminRequired
|
||||
* @NoSubAdminRequired
|
||||
* @PasswordConfirmationRequired
|
||||
*
|
||||
* @param string $account
|
||||
|
|
|
@ -65,7 +65,7 @@ class WebAuthnController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoSubadminRequired
|
||||
* @NoSubAdminRequired
|
||||
* @PasswordConfirmationRequired
|
||||
* @UseSession
|
||||
* @NoCSRFRequired
|
||||
|
@ -83,7 +83,7 @@ class WebAuthnController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoSubadminRequired
|
||||
* @NoSubAdminRequired
|
||||
* @PasswordConfirmationRequired
|
||||
* @UseSession
|
||||
*/
|
||||
|
@ -105,7 +105,7 @@ class WebAuthnController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoSubadminRequired
|
||||
* @NoSubAdminRequired
|
||||
* @PasswordConfirmationRequired
|
||||
*/
|
||||
public function deleteRegistration(int $id): JSONResponse {
|
||||
|
|
|
@ -35,7 +35,7 @@ use OCP\IL10N;
|
|||
|
||||
/**
|
||||
* Verifies whether an user has at least subadmin rights.
|
||||
* To bypass use the `@NoSubadminRequired` annotation
|
||||
* To bypass use the `@NoSubAdminRequired` annotation
|
||||
*/
|
||||
class SubadminMiddleware extends Middleware {
|
||||
/** @var bool */
|
||||
|
@ -65,7 +65,7 @@ class SubadminMiddleware extends Middleware {
|
|||
* @throws \Exception
|
||||
*/
|
||||
public function beforeController($controller, $methodName) {
|
||||
if (!$this->reflector->hasAnnotation('NoSubadminRequired')) {
|
||||
if (!$this->reflector->hasAnnotation('NoSubAdminRequired')) {
|
||||
if (!$this->isSubAdmin) {
|
||||
throw new NotAdminException($this->l10n->t('Logged in user must be a subadmin'));
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ use OCP\IL10N;
|
|||
|
||||
/**
|
||||
* Verifies whether an user has at least subadmin rights.
|
||||
* To bypass use the `@NoSubadminRequired` annotation
|
||||
* To bypass use the `@NoSubAdminRequired` annotation
|
||||
*
|
||||
* @package Tests\Settings\Middleware
|
||||
*/
|
||||
|
@ -64,14 +64,14 @@ class SubadminMiddlewareTest extends \Test\TestCase {
|
|||
$this->subadminMiddleware = new SubadminMiddleware($this->reflector, false, $this->l10n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testBeforeControllerAsUserWithExemption() {
|
||||
$this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\NotAdminException::class);
|
||||
|
||||
$this->reflector
|
||||
->expects($this->once())
|
||||
->method('hasAnnotation')
|
||||
->with('NoSubadminRequired')
|
||||
->with('NoSubAdminRequired')
|
||||
->willReturn(false);
|
||||
$this->subadminMiddleware->beforeController($this->controller, 'foo');
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class SubadminMiddlewareTest extends \Test\TestCase {
|
|||
$this->reflector
|
||||
->expects($this->once())
|
||||
->method('hasAnnotation')
|
||||
->with('NoSubadminRequired')
|
||||
->with('NoSubAdminRequired')
|
||||
->willReturn(true);
|
||||
$this->subadminMiddleware->beforeController($this->controller, 'foo');
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class SubadminMiddlewareTest extends \Test\TestCase {
|
|||
$this->reflector
|
||||
->expects($this->once())
|
||||
->method('hasAnnotation')
|
||||
->with('NoSubadminRequired')
|
||||
->with('NoSubAdminRequired')
|
||||
->willReturn(false);
|
||||
$this->subadminMiddlewareAsSubAdmin->beforeController($this->controller, 'foo');
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class SubadminMiddlewareTest extends \Test\TestCase {
|
|||
$this->reflector
|
||||
->expects($this->once())
|
||||
->method('hasAnnotation')
|
||||
->with('NoSubadminRequired')
|
||||
->with('NoSubAdminRequired')
|
||||
->willReturn(true);
|
||||
$this->subadminMiddlewareAsSubAdmin->beforeController($this->controller, 'foo');
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class SubadminMiddlewareTest extends \Test\TestCase {
|
|||
$this->assertEquals($expectedResponse, $this->subadminMiddleware->afterException($this->controller, 'foo', new NotAdminException('')));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testAfterRegularException() {
|
||||
$this->expectException(\Exception::class);
|
||||
|
||||
|
|
Loading…
Reference in New Issue