diff options
author | Christoph Wurst <christoph@owncloud.com> | 2016-06-01 13:54:08 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@owncloud.com> | 2016-06-01 14:43:47 +0200 |
commit | 5e71d23dedf7fc6a8b9f28d856d57f5516af44ac (patch) | |
tree | df216565c56f53fcbd8d4bb8d253bb39ddd67e13 /core/Middleware/TwoFactorMiddleware.php | |
parent | 7b4459d28d40523c70ec05a733e158f2c14faac4 (diff) | |
download | nextcloud-server-5e71d23dedf7fc6a8b9f28d856d57f5516af44ac.tar.gz nextcloud-server-5e71d23dedf7fc6a8b9f28d856d57f5516af44ac.zip |
remember redirect_url when solving the 2FA challenge
Diffstat (limited to 'core/Middleware/TwoFactorMiddleware.php')
-rw-r--r-- | core/Middleware/TwoFactorMiddleware.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/core/Middleware/TwoFactorMiddleware.php b/core/Middleware/TwoFactorMiddleware.php index 495c4889c20..aa82897ad46 100644 --- a/core/Middleware/TwoFactorMiddleware.php +++ b/core/Middleware/TwoFactorMiddleware.php @@ -1,4 +1,5 @@ <?php + /** * @author Christoph Wurst <christoph@owncloud.com> * @@ -31,6 +32,7 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Middleware; use OCP\AppFramework\Utility\IControllerMethodReflector; +use OCP\IRequest; use OCP\ISession; use OCP\IURLGenerator; @@ -51,6 +53,9 @@ class TwoFactorMiddleware extends Middleware { /** @var IControllerMethodReflector */ private $reflector; + /** @var IRequest */ + private $request; + /** * @param Manager $twoFactorManager * @param Session $userSession @@ -58,12 +63,13 @@ class TwoFactorMiddleware extends Middleware { * @param IURLGenerator $urlGenerator */ public function __construct(Manager $twoFactorManager, Session $userSession, ISession $session, - IURLGenerator $urlGenerator, IControllerMethodReflector $reflector) { + IURLGenerator $urlGenerator, IControllerMethodReflector $reflector, IRequest $request) { $this->twoFactorManager = $twoFactorManager; $this->userSession = $userSession; $this->session = $session; $this->urlGenerator = $urlGenerator; $this->reflector = $reflector; + $this->request = $request; } /** @@ -110,7 +116,9 @@ class TwoFactorMiddleware extends Middleware { public function afterException($controller, $methodName, Exception $exception) { if ($exception instanceof TwoFactorAuthRequiredException) { - return new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.selectChallenge')); + return new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.selectChallenge', [ + 'redirect_url' => urlencode($this->request->server['REQUEST_URI']), + ])); } if ($exception instanceof UserAlreadyLoggedInException) { return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index')); |