diff options
author | Joas Schilling <coding@schilljs.com> | 2016-08-26 16:03:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-26 16:03:05 +0200 |
commit | 89c78bbce48ccd75e42245bf1d92910c50e2648f (patch) | |
tree | 7362a768fc265e36cc5f97e2459622d399962595 /lib/private/Authentication/TwoFactorAuth | |
parent | c20aef87956ce0cc442d809f417f40d61bcd1485 (diff) | |
parent | 6af2efb67931863b27d96c74cdff1d2ca2615e52 (diff) | |
download | nextcloud-server-89c78bbce48ccd75e42245bf1d92910c50e2648f.tar.gz nextcloud-server-89c78bbce48ccd75e42245bf1d92910c50e2648f.zip |
Merge pull request #1031 from nextcloud/2fa-infinite-redirect-loop
prevent infinite redirect loops if the there is no 2fa provider to pass
Diffstat (limited to 'lib/private/Authentication/TwoFactorAuth')
-rw-r--r-- | lib/private/Authentication/TwoFactorAuth/Manager.php | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/private/Authentication/TwoFactorAuth/Manager.php b/lib/private/Authentication/TwoFactorAuth/Manager.php index 66bcafbce71..143fe7dc927 100644 --- a/lib/private/Authentication/TwoFactorAuth/Manager.php +++ b/lib/private/Authentication/TwoFactorAuth/Manager.php @@ -165,10 +165,24 @@ class Manager { /** * Check if the currently logged in user needs to pass 2FA * + * @param IUser $user the currently logged in user * @return boolean */ - public function needsSecondFactor() { - return $this->session->exists(self::SESSION_UID_KEY); + public function needsSecondFactor(IUser $user = null) { + if (is_null($user) || !$this->session->exists(self::SESSION_UID_KEY)) { + return false; + } + + if (!$this->isTwoFactorAuthenticated($user)) { + // There is no second factor any more -> let the user pass + // This prevents infinite redirect loops when a user is about + // to solve the 2FA challenge, and the provider app is + // disabled the same time + $this->session->remove(self::SESSION_UID_KEY); + return false; + } + + return true; } /** |