Skip to content

Commit 93a1f08

Browse files
author
Carlos Garcia
committed
Solucionado bug con la autenticación en 2 pasos
1 parent 7042112 commit 93a1f08

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

Core/Controller/EditUser.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ protected function createViews()
100100
$this->setSettings($mvn, 'btnOptions', false);
101101
$this->setSettings($mvn, 'btnPrint', false);
102102

103-
// add two factor authentication tab
104-
$this->createViewsTwofactor();
103+
// add two-factor authentication tab
104+
$this->createViewsTwoFactor();
105105

106106
// add roles tab
107107
if ($this->user->admin) {
@@ -115,7 +115,7 @@ protected function createViews()
115115
$this->createViewsEmails();
116116
}
117117

118-
protected function createViewsTwofactor(string $viewName = 'UserTwoFactor'): void
118+
protected function createViewsTwoFactor(string $viewName = 'UserTwoFactor'): void
119119
{
120120
$this->addHtmlView($viewName, 'Tab\UserTwoFactor', 'User', 'two-factor-auth', 'fa-solid fa-key');
121121
}
@@ -308,7 +308,8 @@ protected function loadData($viewName, $view)
308308
// prevent user self-destruction
309309
$this->setSettings($viewName, 'btnDelete', false);
310310
}
311-
// is the user is admin, hide the EditRoleUser tab
311+
312+
// if the user is admin, hide the EditRoleUser tab
312313
if ($view->model->admin && array_key_exists('EditRoleUser', $this->views)) {
313314
$this->setSettings('EditRoleUser', 'active', false);
314315
}

Core/Controller/Login.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ class Login implements ControllerInterface
4444
/** @var string */
4545
public $title = 'Login';
4646

47+
/** @var string */
48+
public $two_factor_user;
49+
4750
/** @var boolean */
4851
private $two_factor_view = false;
4952

50-
5153
public function __construct(string $className, string $url = '')
5254
{
5355
}
@@ -310,6 +312,7 @@ protected function loginAction(Request $request): void
310312
}
311313

312314
if ($user->two_factor_enabled) {
315+
$this->two_factor_user = $user->nick;
313316
$this->two_factor_view = true;
314317
return;
315318
}
@@ -320,7 +323,9 @@ protected function loginAction(Request $request): void
320323
protected function validCodeAction(Request $request): void
321324
{
322325
$user = new User();
323-
$user->loadFromCode($request->request->get('fsNick'));
326+
if (!$user->loadFromCode($request->request->get('fsNick'))) {
327+
Tools::log()->warning('user-not-found');
328+
}
324329

325330
if (!TwoFactorManager::verifyCode($user->two_factor_secret_key, $request->request->get('fsCode'))) {
326331
Tools::log()->warning('login-2fa-fail');

Core/View/Login/TwoFactor.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
<form action="{{ asset('login') }}" method="post" class="form">
99
{{ formToken() }}
1010
<input type="hidden" name="action" value="valid-totp">
11-
<input type="hidden" name="fsNick" value="{{ fsc.user.nick }}">
11+
<input type="hidden" name="fsNick" value="{{ fsc.two_factor_user }}">
1212
<div class="card mt-4">
1313
<a href="{{ asset('login') }}">
1414
{% set idfile = settings('default','idloginimage', 0) %}
1515
{{ _self.loadLogo(idfile) }}
1616
</a>
1717
<div class="card-body">
18-
<p class="card-text text-center">Ingrese el codigo TOTP</p>
18+
<p class="card-text text-center">Ingrese el código TOTP</p>
1919
<div class="mb-3">
2020
<div class="input-group">
2121
<span class="input-group-text">
22-
<i class="fa-solid fa-user fa-fw" aria-hidden="true"></i>
22+
<i class="fa-solid fa-user fa-fw" aria-hidden="true"></i>
2323
</span>
2424
<input type="text" name="fsCode" class="form-control" maxlength="50"
2525
placeholder="{{ trans('code') }}" required autocomplete="off"

Core/View/Tab/UserTwoFactor.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
<div class="input-group mb-3">
1818
<input type="text" class="form-control" name="codetime" placeholder="{{ trans('code') }}" required/>
1919
<button class="btn btn-primary" type="submit">
20-
{{ trans('save') }}
21-
</button>
20+
{{ trans('save') }}
21+
</button>
2222
</div>
2323
</form>
2424
</div>

0 commit comments

Comments
 (0)