Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
Open sidebar
ISPConfig
ISPConfig 3
Commits
8eaa875b
Unverified
Commit
8eaa875b
authored
Mar 27, 2022
by
Helmo
Browse files
Only regenerate code when sending a mail $new_otp_code is not stored unhashed
parent
f30ba514
Changes
1
Hide whitespace changes
Inline
Side-by-side
interface/web/login/otp.php
View file @
8eaa875b
...
...
@@ -101,9 +101,8 @@ if($_SESSION['otp']['type'] == 'email') {
$max_time
=
600
;
// time in seconds until the code gets invalidated
$code_length
=
6
;
if
(
isset
(
$_POST
[
'code'
])
&&
strlen
(
$_POST
[
'code'
])
==
$code_length
&&
isset
(
$_SESSION
[
'otp'
][
'code'
]))
{
if
(
isset
(
$_POST
[
'code'
])
&&
strlen
(
$_POST
[
'code'
])
==
$code_length
&&
isset
(
$_SESSION
[
'otp'
][
'code
_hash
'
]))
{
if
(
strlen
(
$_SESSION
[
'otp'
][
'code'
])
!=
$code_length
)
die
();
// wrong code lenght, this should never happen
$user
=
$app
->
db
->
queryOneRecord
(
'SELECT otp_attempts FROM sys_user WHERE userid = ?'
,
$_SESSION
[
's_pending'
][
'user'
][
'userid'
]);
...
...
@@ -128,16 +127,13 @@ if($_SESSION['otp']['type'] == 'email') {
}
}
//* set code
if
(
!
isset
(
$_SESSION
[
'otp'
][
'code'
])
||
empty
(
$_SESSION
[
'otp'
][
'code'
]))
{
//* Send code via email
if
(
!
isset
(
$_SESSION
[
'otp'
][
'sent'
])
||
$_GET
[
'action'
]
==
'resend'
)
{
// Generate new code
$new_otp_code
=
random_int
(
100000
,
999999
);
$_SESSION
[
'otp'
][
'code_hash'
]
=
password_hash
(
$new_otp_code
,
PASSWORD_DEFAULT
);
//$_SESSION['otp']['code_debug'] = $new_otp_code; # for DEBUG only.
$_SESSION
[
'otp'
][
'starttime'
]
=
time
();
}
//* Send code via email
if
(
!
isset
(
$_SESSION
[
'otp'
][
'sent'
])
||
$_GET
[
'action'
]
==
'resend'
)
{
//* Ensure that code is not sent too often
if
(
isset
(
$_SESSION
[
'otp'
][
'sent'
])
&&
$_SESSION
[
'otp'
][
'sent'
]
>
$max_code_resend
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment