diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2021-10-15 10:32:17 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2021-10-15 10:32:17 +0000 |
| commit | ac32af21f9e0fb51aab94cfa75106b41cf5541a6 (patch) | |
| tree | cc692e981c06f5186f358b2fe6b2300fd89fba1d /lib/classes/TwoFactorAuth.php | |
| parent | 230e8a4c17e6f901dc0e62d282b97e8a79769df8 (diff) | |
fixes #128, fixes #130
Diffstat (limited to 'lib/classes/TwoFactorAuth.php')
| -rw-r--r-- | lib/classes/TwoFactorAuth.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/classes/TwoFactorAuth.php b/lib/classes/TwoFactorAuth.php index f66b667..ef7e668 100644 --- a/lib/classes/TwoFactorAuth.php +++ b/lib/classes/TwoFactorAuth.php @@ -221,9 +221,10 @@ final class TwoFactorAuth echo $GLOBALS['template_factory']->render( 'tfa-validate.php', $_SESSION[self::SESSION_DATA] + [ - 'secret' => $this->secret, - 'text' => $text, - 'blocked' => $this->isBlocked(), + 'secret' => $this->secret, + 'text' => $text, + 'blocked' => $this->isBlocked(), + 'duration' => Config::get()->TFA_TRUST_DURATION, ], 'layouts/base.php' ); @@ -250,11 +251,14 @@ final class TwoFactorAuth */ private function registerSecretInCookie() { + $lifetime_in_days = Config::get()->TFA_TRUST_DURATION; + $lifetime = $lifetime_in_days > 0 ? strtotime("+{$lifetime_in_days} days") : 2147483647; + $timeslice = mt_rand(0, PHP_INT_MAX); setcookie( self::COOKIE_KEY, implode(':', [$this->secret->getToken($timeslice), $timeslice]), - strtotime('+30 days'), + $lifetime, $GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP'] ); } |
