File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed
Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -101,9 +101,8 @@ function finish_2fa_success($msg = '') {
101101 $ max_time = 600 ; // time in seconds until the code gets invalidated
102102 $ code_length = 6 ;
103103
104- if (isset ($ _POST ['code ' ]) && strlen ($ _POST ['code ' ]) == $ code_length && isset ($ _SESSION ['otp ' ]['code ' ])) {
104+ if (isset ($ _POST ['code ' ]) && strlen ($ _POST ['code ' ]) == $ code_length && isset ($ _SESSION ['otp ' ]['code_hash ' ])) {
105105
106- if (strlen ($ _SESSION ['otp ' ]['code ' ]) != $ code_length ) die (); // wrong code lenght, this should never happen
107106
108107 $ user = $ app ->db ->queryOneRecord ('SELECT otp_attempts FROM sys_user WHERE userid = ? ' ,$ _SESSION ['s_pending ' ]['user ' ]['userid ' ]);
109108
@@ -128,16 +127,13 @@ function finish_2fa_success($msg = '') {
128127 }
129128 }
130129
131- //* set code
132- if (!isset ($ _SESSION ['otp ' ]['code ' ]) || empty ($ _SESSION ['otp ' ]['code ' ])) {
130+ //* Send code via email
131+ if (!isset ($ _SESSION ['otp ' ]['sent ' ]) || $ _GET ['action ' ] == 'resend ' ) {
132+ // Generate new code
133133 $ new_otp_code = random_int (100000 , 999999 );
134134 $ _SESSION ['otp ' ]['code_hash ' ] = password_hash ($ new_otp_code , PASSWORD_DEFAULT );
135135 //$_SESSION['otp']['code_debug'] = $new_otp_code; # for DEBUG only.
136136 $ _SESSION ['otp ' ]['starttime ' ] = time ();
137- }
138-
139- //* Send code via email
140- if (!isset ($ _SESSION ['otp ' ]['sent ' ]) || $ _GET ['action ' ] == 'resend ' ) {
141137
142138 //* Ensure that code is not sent too often
143139 if (isset ($ _SESSION ['otp ' ]['sent ' ]) && $ _SESSION ['otp ' ]['sent ' ] > $ max_code_resend ) {
You can’t perform that action at this time.
0 commit comments