Skip to content

Commit 08a42de

Browse files
committed
Add a UI element for OTP in the User Settings form
1 parent 745b73c commit 08a42de

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

interface/web/login/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@
281281
} else {
282282

283283
//* Do 2FA authentication
284-
if($user['otp_enabled'] != 'n') {
284+
if(!empty($user['otp_type']) && $user['otp_type'] != 'none') {
285285

286286
//* Save session in pending state and destroy original session
287287
$_SESSION['s_pending'] = $_SESSION['s'];

interface/web/tools/form/user_settings.tform.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@
119119
}
120120
}
121121

122+
$otp_method_list = array(
123+
'none' => 'none',
124+
'email' => 'email',
125+
);
122126
//* Load themes
123127
$themes_list = array();
124128
$handle = @opendir(ISPC_THEMES_PATH);
@@ -163,6 +167,25 @@
163167
'rows' => '',
164168
'cols' => ''
165169
),
170+
'otp_type' => array(
171+
'datatype' => 'VARCHAR',
172+
'formtype' => 'SELECT',
173+
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
174+
'errmsg'=> 'oth_auth_empty'),
175+
1 => array ( 'type' => 'REGEX',
176+
'regex' => '/^[a-z0-9\_]{0,64}$/',
177+
'errmsg'=> 'otp_auth_regex'),
178+
),
179+
'regex' => '',
180+
'errmsg' => '',
181+
'default' => '',
182+
'value' => $otp_method_list,
183+
'separator' => '',
184+
'width' => '30',
185+
'maxlength' => '255',
186+
'rows' => '',
187+
'cols' => ''
188+
),
166189
'language' => array (
167190
'datatype' => 'VARCHAR',
168191
'formtype' => 'SELECT',

interface/web/tools/lib/lang/en_usersettings.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ $wb['startmodule_empty'] = 'Startmodule empty.';
1616
$wb['startmodule_regex'] = 'Invalid chars in Startmodule.';
1717
$wb['app_theme_empty'] = 'App theme empty.';
1818
$wb['app_theme_regex'] = 'Invalid chars in App theme.';
19+
$wb['otp_auth_txt'] = '2-Factor Authentication';
1920
?>

interface/web/tools/templates/user_settings.htm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
<div id="confirmpasswordOK" style="display:none;" class="confirmpasswordok">{tmpl_var name='password_match_txt'}</div>
2727
</div>
2828
</div>
29+
<div class="form-group">
30+
<label for="2fa" class="col-sm-3 control-label">{tmpl_var name='otp_auth_txt'}</label>
31+
<div class="col-sm-9">
32+
<select name="otp_type" id="otp_type" class="form-control">
33+
{tmpl_var name='otp_type'}
34+
</select>
35+
</div>
36+
</div>
2937
<div class="form-group">
3038
<label for="language" class="col-sm-3 control-label">{tmpl_var name='language_txt'}</label>
3139
<div class="col-sm-9"><select name="language" id="language" class="form-control flags">

0 commit comments

Comments
 (0)