1111
1212use Exception ;
1313use OC \AppFramework \Http \Attributes \TwoFactorSetUpDoneRequired ;
14- use OC \AppFramework \Middleware \MiddlewareUtils ;
1514use OC \Authentication \Exceptions \TwoFactorAuthRequiredException ;
1615use OC \Authentication \Exceptions \UserAlreadyLoggedInException ;
1716use OC \Authentication \TwoFactorAuth \Manager ;
2322use OCP \AppFramework \Http \Attribute \NoTwoFactorRequired ;
2423use OCP \AppFramework \Http \RedirectResponse ;
2524use OCP \AppFramework \Middleware ;
25+ use OCP \AppFramework \Utility \IControllerMethodReflector ;
2626use OCP \Authentication \TwoFactorAuth \ALoginSetupController ;
2727use OCP \IRequest ;
2828use OCP \ISession ;
@@ -36,7 +36,7 @@ public function __construct(
3636 private Session $ userSession ,
3737 private ISession $ session ,
3838 private IURLGenerator $ urlGenerator ,
39- private MiddlewareUtils $ middlewareUtils ,
39+ private IControllerMethodReflector $ reflector ,
4040 private IRequest $ request ,
4141 ) {
4242 }
@@ -46,9 +46,7 @@ public function __construct(
4646 * @param string $methodName
4747 */
4848 public function beforeController ($ controller , $ methodName ) {
49- $ reflectionMethod = new ReflectionMethod ($ controller , $ methodName );
50-
51- if ($ this ->middlewareUtils ->hasAnnotationOrAttribute ($ reflectionMethod , 'NoTwoFactorRequired ' , NoTwoFactorRequired::class)) {
49+ if ($ this ->reflector ->hasAnnotationOrAttribute ('NoTwoFactorRequired ' , NoTwoFactorRequired::class)) {
5250 // Route handler explicitly marked to work without finished 2FA are
5351 // not blocked
5452 return ;
@@ -59,6 +57,7 @@ public function beforeController($controller, $methodName) {
5957 return ;
6058 }
6159
60+ $ reflectionMethod = new ReflectionMethod ($ controller , $ methodName );
6261 if ($ controller instanceof TwoFactorChallengeController
6362 && $ this ->userSession ->getUser () !== null
6463 && !$ reflectionMethod ->getAttributes (TwoFactorSetUpDoneRequired::class)) {
0 commit comments