Skip to content

Commit 37138e0

Browse files
committed
Merge branch '2.0'
2 parents 7620027 + e904093 commit 37138e0

8 files changed

Lines changed: 58 additions & 37 deletions

File tree

src/lib/Controllers/AuthenticatorController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ private function sendResetEmail(AuthenticatorData $authenticatorData)
345345
}
346346

347347
return false;
348+
} catch (AuthenticatorException $e) {
349+
throw $e;
348350
} catch (\Exception $e) {
349351
processException($e);
350352

src/lib/Controllers/AuthenticatorLoginController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ final class AuthenticatorLoginController extends ControllerBase
5353
* @throws \DI\DependencyException
5454
* @throws \DI\NotFoundException
5555
* @throws \SP\Services\Auth\AuthException
56+
* @throws \SP\Core\Exceptions\SessionTimeout
5657
*/
5758
public function indexAction()
5859
{
@@ -69,6 +70,8 @@ public function indexAction()
6970
$this->view->assign('useFixedHeader', true);
7071
$this->view->assign('useMenu', false);
7172
$this->view->assign('route', 'authenticator/checkCode');
73+
$this->view->assign('isMailEnabled', $this->configData->isMailEnabled());
74+
$this->view->assign('recoveryGraceTime', Plugin::RECOVERY_GRACE_TIME / 3600);
7275

7376
$this->checkExpireTime($this->userData->getId());
7477

src/lib/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function getAuthor()
202202
*/
203203
public function getVersion()
204204
{
205-
return [2, 0, 2];
205+
return [2, 0, 3];
206206
}
207207

208208
/**

src/lib/Services/AuthenticatorService.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ public function getQrCodeFromServer(string $login, string $iv)
185185
* @return string
186186
* @throws AuthenticatorException
187187
* @throws EnvironmentIsBrokenException
188-
* @throws \SP\Core\Exceptions\ConstraintException
189-
* @throws \SP\Core\Exceptions\QueryException
190-
* @throws \SP\Repositories\NoSuchItemException
191188
*/
192189
public function pickRecoveryCode(AuthenticatorData $authenticatorData)
193190
{
@@ -196,11 +193,7 @@ public function pickRecoveryCode(AuthenticatorData $authenticatorData)
196193
$numCodes = count($codes);
197194

198195
if ($numCodes > 0) {
199-
$code = array_pop($codes);
200-
201-
$this->saveRecoveryCodes($codes, $authenticatorData);
202-
203-
return $code;
196+
return $codes[1];
204197
}
205198

206199
if ($recoveryTime === 0
@@ -209,11 +202,7 @@ public function pickRecoveryCode(AuthenticatorData $authenticatorData)
209202
) {
210203
$codes = $this->generateRecoveryCodes();
211204

212-
$code = array_pop($codes);
213-
214-
$this->saveRecoveryCodes($codes, $authenticatorData);
215-
216-
return $code;
205+
return $codes[1];
217206
}
218207

219208
throw new AuthenticatorException(_t('authenticator', 'There aren\'t any recovery codes available'));

src/public/js/plugin.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,15 @@ sysPass.Plugins.Authenticator = function (Common) {
3838
sysPassApp.msg.out(json);
3939

4040
if (json.status === 0) {
41-
setTimeout(function () {
42-
sysPassApp.util.redirect(json.data.url);
43-
}, 1000);
41+
if (json.data.url !== undefined) {
42+
setTimeout(function () {
43+
sysPassApp.util.redirect(json.data.url);
44+
}, 1000);
45+
}
4446
}
47+
48+
document.querySelector('.mdl-js-checkbox').MaterialCheckbox.uncheck();
49+
$obj.find("#pin").val('');
4550
});
4651
},
4752
save: function ($obj) {

src/public/js/plugin.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/themes/material-blue/views/login/index.inc

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22
/**
3-
* @var \SP\Core\UI\ThemeIcons $icons
4-
* @var \SP\Config\ConfigData $configData
5-
* @var callable $_getvar
6-
* @var \SP\Mvc\View\Template $this
3+
* @var \SP\Core\UI\ThemeIcons $icons
4+
* @var \SP\Config\ConfigData $configData
5+
* @var callable $_getvar
6+
* @var \SP\Mvc\View\Template $this
77
*/
88
?>
99
<div id="actions" class="authenticator-2fa" align="center">
@@ -17,20 +17,41 @@
1717
<legend><?php echo _t('authenticator', 'Two Factor Authentication'); ?></legend>
1818
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
1919
<input id="pin" name="pin" type="text"
20-
pattern="([0-9]{6}|[0-9a-f]{20})" class="mdl-textfield__input mdl-color-text--indigo-400"
20+
pattern="([0-9]{6}|[0-9a-f]{20})"
21+
class="mdl-textfield__input mdl-color-text--indigo-400"
2122
maxlength="20"/>
2223
<label class="mdl-textfield__label"
2324
for="pin"><?php echo _t('authenticator', 'Enter code'); ?></label>
2425
</div>
2526

26-
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="code_reset">
27-
<input type="checkbox" name="code_reset" id="code_reset" class="mdl-checkbox__input">
28-
<span class="mdl-checkbox__label"><?php echo _t('authenticator', 'Forgot my code'); ?></span>
29-
</label>
27+
<?php if ($_getvar('isMailEnabled')): ?>
28+
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect"
29+
for="code_reset">
30+
<input type="checkbox" name="code_reset" id="code_reset"
31+
class="mdl-checkbox__input">
32+
<span class="mdl-checkbox__label"><?php echo _t('authenticator', 'Forgot my code'); ?></span>
33+
34+
<div id="help-2fa"
35+
class="icon material-icons <?php echo $icons->getIconHelp()->getClass(); ?>"><?php echo $icons->getIconHelp()->getIcon(); ?></div>
36+
</label>
37+
38+
39+
<div class="mdl-tooltip mdl-tooltip--large" for="help-2fa">
40+
<p>
41+
<?php echo _t('authenticator', 'This will send an email with a recovery code. You don\'t need to enter any code, only click on "Log In".'); ?>
42+
</p>
43+
44+
<p>
45+
<?php echo _t('authenticator', sprintf('If there aren\'t any recovery codes left, you will need to wait %dh for new codes', $_getvar('recoveryGraceTime'))); ?>
46+
</p>
47+
</div>
48+
<?php endif; ?>
3049

3150
<?php if ($_getvar('from') && $_getvar('from_hash')): ?>
32-
<input type="hidden" name="from" value="<?php echo $_getvar('from'); ?>"/>
33-
<input type="hidden" name="h" value="<?php echo $_getvar('from_hash'); ?>"/>
51+
<input type="hidden" name="from"
52+
value="<?php echo $_getvar('from'); ?>"/>
53+
<input type="hidden" name="h"
54+
value="<?php echo $_getvar('from_hash'); ?>"/>
3455
<?php endif; ?>
3556

3657
<input type="hidden" name="sk" value=""/>
@@ -46,7 +67,8 @@
4667
<?php echo _t('authenticator', 'Back'); ?>
4768
</button>
4869

49-
<button id="btnLogin" class="mdl-button mdl-js-button mdl-button--raised mdl-button--primary">
70+
<button id="btnLogin"
71+
class="mdl-button mdl-js-button mdl-button--raised mdl-button--primary">
5072
<?php echo _t('authenticator', 'Log in'); ?>
5173
<i class="material-icons"
5274
title="<?php echo _t('authenticator', 'Request'); ?>"><?php echo $icons->getIconPlay()->getIcon(); ?></i>

version.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Authenticator": {
3-
"version": "2.0.2",
4-
"build": "19020901"
3+
"version": "2.0.3",
4+
"build": "19021201"
55
}
66
}

0 commit comments

Comments
 (0)