Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
use OCP\IUserSession;
use OCP\Session\Exceptions\SessionNotAvailableException;
use OCP\User\Backend\IPasswordConfirmationBackend;
use ReflectionAttribute;
use ReflectionMethod;

class PasswordConfirmationMiddleware extends Middleware {
private array $excludedUserBackEnds = ['user_saml' => true, 'user_globalsiteselector' => true];
Expand Down Expand Up @@ -75,8 +73,7 @@ public function beforeController(Controller $controller, string $methodName): vo
// No scope to test
}

$reflectionMethod = new ReflectionMethod($controller, $methodName);
if ($this->isPasswordConfirmationStrict($reflectionMethod)) {
if ($this->isPasswordConfirmationStrict()) {
$password = $this->request->getHeader('PHP_AUTH_PW');

if ($password === '') {
Expand All @@ -103,9 +100,8 @@ private function needsPasswordConfirmation(): bool {
return $this->reflector->hasAnnotationOrAttribute('PasswordConfirmationRequired', PasswordConfirmationRequired::class);
}

private function isPasswordConfirmationStrict(ReflectionMethod $reflectionMethod): bool {
/** @var ReflectionAttribute<PasswordConfirmationRequired>[] $attributes */
$attributes = $reflectionMethod->getAttributes(PasswordConfirmationRequired::class);
return !empty($attributes) && ($attributes[0]->newInstance()->getStrict());
private function isPasswordConfirmationStrict(): bool {
$attribute = $this->reflector->getAttribute(PasswordConfirmationRequired::class);
return $attribute !== null && ($attribute->newInstance()->getStrict());
}
}
Loading