summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2016-08-29 18:36:39 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2016-08-29 18:36:39 +0200
commit291dd0bd31e344b294d6dda506c614df7ea12382 (patch)
tree55d473e674107a926d8c90e71105955b742f7c9d /core
parent402feb9e13d4a8a1b3c0ed5aeff301abcd4280e4 (diff)
downloadnextcloud-server-291dd0bd31e344b294d6dda506c614df7ea12382.tar.gz
nextcloud-server-291dd0bd31e344b294d6dda506c614df7ea12382.zip
redirect to 2fa provider if there's only one active for the user
Diffstat (limited to 'core')
-rw-r--r--core/Controller/LoginController.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php
index 67e1e215289..b686b34b2ce 100644
--- a/core/Controller/LoginController.php
+++ b/core/Controller/LoginController.php
@@ -242,12 +242,26 @@ class LoginController extends Controller {
if ($this->twoFactorManager->isTwoFactorAuthenticated($loginResult)) {
$this->twoFactorManager->prepareTwoFactorLogin($loginResult);
+
+ $providers = $this->twoFactorManager->getProviders($loginResult);
+ if (count($providers) === 1) {
+ // Single provider, hence we can redirect to that provider's challenge page directly
+ /* @var $provider IProvider */
+ $provider = array_pop($providers);
+ $url = 'core.TwoFactorChallenge.showChallenge';
+ $urlParams = [
+ 'challengeProviderId' => $provider->getId(),
+ ];
+ } else {
+ $url = 'core.TwoFactorChallenge.selectChallenge';
+ $urlParams = [];
+ }
+
if (!is_null($redirect_url)) {
- return new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.selectChallenge', [
- 'redirect_url' => $redirect_url
- ]));
+ $urlParams['redirect_url'] = $redirect_url;
}
- return new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.selectChallenge'));
+
+ return new RedirectResponse($this->urlGenerator->linkToRoute($url, $urlParams));
}
return $this->generateRedirect($redirect_url);