forked from alexandregz/twofactor_gauthenticator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twofactor_gauthenticator_form.js
41 lines (33 loc) · 1.37 KB
/
twofactor_gauthenticator_form.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
if (window.rcmail) {
rcmail.addEventListener('init', function() {
// remove the user/password/... input from login
$('form > table > tbody > tr').each(function(){
$(this).remove();
});
// change task & action
$('form').attr('action', './');
$('input[name=_task]').attr('value', 'mail');
$('input[name=_action]').attr('value', '');
//determine twofactor field type based on config settings
if(rcmail.env.twofactor_formfield_as_password)
var twoFactorCodeFieldType = 'password';
else
var twoFactorCodeFieldType = 'text';
//twofactor input form
var text = '';
text += '<tr>';
text += '<td class="title"><label for="2FA_code">'+rcmail.gettext('two_step_verification_form', 'twofactor_gauthenticator')+'</label></td>';
text += '<td class="input"><input name="_code_2FA" id="2FA_code" size="10" autocapitalize="off" autocomplete="off" type="' + twoFactorCodeFieldType + '" maxlength="10"></td>';
text += '</tr>';
// remember option
if(rcmail.env.allow_save_device_30days){
text += '<tr>';
text += '<td class="title" colspan="2"><input type="checkbox" id="remember_2FA" name="_remember_2FA" value="yes"/>'+rcmail.gettext('dont_ask_me_30days', 'twofactor_gauthenticator')+'</td>';
text += '</tr>';
}
// create textbox
$('form > table > tbody:last').append(text);
// focus
$('#2FA_code').focus();
});
};