Skip to content

Commit b9a4f8c

Browse files
committed
Whitespace cleanup
1 parent d466b94 commit b9a4f8c

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

interface/web/login/otp.php

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ function finish_2fa_success($msg = '') {
7878
//* Handle recovery code
7979
if(isset($_POST['code']) && strlen($_POST['code']) == $otp_recovery_code_length && $_SESSION['otp']['recovery']) {
8080
//* TODO Recovery code handling
81-
81+
8282
$user = $app->db->queryOneRecord('SELECT otp_attempts FROM sys_user WHERE userid = ?',$_SESSION['s_pending']['user']['userid']);
83-
83+
8484
//* We allow one more try to enter recovery code
8585
if($user['otp_attempts'] > $max_global_code_retry + 1) {
8686
die("Sorry, contact your administrator.");
8787
}
88-
88+
8989
if ($_SESSION['otp']['recovery'] == $_POST['code']) {
9090
finish_2fa_success('via 2fa recovery code');
9191
}
@@ -99,13 +99,13 @@ function finish_2fa_success($msg = '') {
9999
$max_code_resend = 3;
100100
$max_time = 600; // time in seconds until the code gets invalidated
101101
$code_length = 6;
102-
102+
103103
if(isset($_POST['code']) && strlen($_POST['code']) == $code_length && isset($_SESSION['otp']['code'])) {
104-
104+
105105
if(strlen($_SESSION['otp']['code']) != $code_length) die(); // wrong code lenght, this should never happen
106106

107107
$user = $app->db->queryOneRecord('SELECT otp_attempts FROM sys_user WHERE userid = ?',$_SESSION['s_pending']['user']['userid']);
108-
108+
109109
//* Check if we reached limits
110110
if($_SESSION['otp']['sent'] > $max_code_resend
111111
|| $_SESSION['otp']['session_attempts'] > $max_session_code_retry
@@ -116,7 +116,7 @@ function finish_2fa_success($msg = '') {
116116
unset($_SESSION['s_pending']);
117117
$app->error('2FA failed','index.php');
118118
}
119-
119+
120120
//* 2fa success
121121
if($_POST['code'] == $_SESSION['otp']['code']) {
122122
finish_2fa_success();
@@ -126,36 +126,35 @@ function finish_2fa_success($msg = '') {
126126
$app->db->query('UPDATE `sys_user` SET otp_attempts=otp_attempts + 1 WHERE userid = ?', $_SESSION['s_pending']['user']['userid']);
127127
}
128128
}
129-
129+
130130
//* set code
131131
if(!isset($_SESSION['otp']['code']) || empty($_SESSION['otp']['code'])) {
132132
// Random int between 10^($code_length-1) and 10^$code_length
133133
$_SESSION['otp']['code'] = rand(pow(10, $code_length - 1), pow(10, $code_length) - 1);
134134
$_SESSION['otp']['starttime'] = time();
135135
}
136-
136+
137137
//* Send code via email
138138
if(!isset($_SESSION['otp']['sent']) || $_GET['action'] == 'resend') {
139-
139+
140140
//* Ensure that code is not sent too often
141141
if(isset($_SESSION['otp']['sent']) && $_SESSION['otp']['sent'] > $max_code_resend) {
142142
$app->error('Code resend limit reached','index.php');
143143
}
144-
144+
145145
$app->uses('functions');
146146
$app->uses('getconf');
147147
$system_config = $app->getconf->get_global_config();
148148
$from = $system_config['mail']['admin_mail'];
149149

150-
151150
//* send email
152151
$email_to = $_SESSION['otp']['data'];
153152
$subject = 'ISPConfig Login authentication';
154153
$text = 'Your One time login code is ' . $_SESSION['otp']['code'] . PHP_EOL
155154
. 'This code is valid for 10 minutes' . PHP_EOL;
156-
155+
157156
$app->functions->mail($email_to, $subject, $text, $from);
158-
157+
159158
//* increase sent counter
160159
if(!isset($_SESSION['otp']['sent'])) {
161160
$_SESSION['otp']['sent'] = 1;
@@ -164,10 +163,9 @@ function finish_2fa_success($msg = '') {
164163
}
165164

166165
}
167-
166+
168167
//* Show form to enter email code
169168
// ... below
170-
171169

172170
} else {
173171
//* unsupported 2fa type
@@ -191,21 +189,16 @@ function finish_2fa_success($msg = '') {
191189
$app->tpl->newTemplate('main_login.tpl.htm');
192190
$app->tpl->setInclude('content_tpl', 'templates/otp.htm');
193191

194-
192+
195193
//* SET csrf token
196194
$csrf_token = $app->auth->csrf_token_get('language_edit');
197195
$app->tpl->setVar('_csrf_id',$csrf_token['csrf_id']);
198196
$app->tpl->setVar('_csrf_key',$csrf_token['csrf_key']);
199197
#$app->tpl->setVar('msg', print_r($_SESSION['otp'], 1));
200198

201-
202199
require ISPC_ROOT_PATH.'/web/login/lib/lang/'.$app->functions->check_language($conf['language']).'.lng';
203200
$app->tpl->setVar($wb);
204201

205-
206-
207-
208-
209202
$app->tpl_defaults();
210203
$app->tpl->pparse();
211204

0 commit comments

Comments
 (0)