Skip to content
Closed
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
13 changes: 10 additions & 3 deletions core/Middleware/TwoFactorMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ public function __construct(
/**
* @param Controller $controller
* @param string $methodName
* @throws TwoFactorAuthRequiredException
* @throws UserAlreadyLoggedInException
* @throws Exception
*/
public function beforeController($controller, $methodName) {
public function beforeController(Controller $controller, string $methodName): void {
if ($this->reflector->hasAnnotation('NoTwoFactorRequired')) {
// Route handler explicitly marked to work without finished 2FA are
// not blocked
Expand Down Expand Up @@ -111,7 +114,11 @@ public function beforeController($controller, $methodName) {
// TODO: dont check/enforce 2FA if a auth token is used
}

private function checkTwoFactor(Controller $controller, $methodName, IUser $user) {
/**
* @throws UserAlreadyLoggedInException
* @throws TwoFactorAuthRequiredException
*/
private function checkTwoFactor(Controller $controller, string $methodName, IUser $user): void {
// If two-factor auth is in progress disallow access to any controllers
// defined within "LoginController".
$needsSecondFactor = $this->twoFactorManager->needsSecondFactor($user);
Expand All @@ -129,7 +136,7 @@ private function checkTwoFactor(Controller $controller, $methodName, IUser $user
}
}

public function afterException($controller, $methodName, Exception $exception) {
public function afterException(Controller $controller, string $methodName, Exception $exception): RedirectResponse {
if ($exception instanceof TwoFactorAuthRequiredException) {
$params = [];
if (isset($this->request->server['REQUEST_URI'])) {
Expand Down