author | Dan Fuhry <dan@enanocms.org> |
Fri, 30 Jun 2017 17:49:12 -0400 | |
changeset 39 | 6212d849ab08 |
permissions | -rw-r--r-- |
39
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
1 |
// sample OTP: |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
2 |
// ttttvvvvvvcurikvhjcvnlnbecbkubjvuittbifhndhn |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
3 |
// charset: cbdefghijklnrtuv |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
4 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
5 |
var yk_interval = false; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
6 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
7 |
var YK_SEC_NORMAL_USERNAME = 1; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
8 |
var YK_SEC_NORMAL_PASSWORD = 2; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
9 |
var YK_SEC_ELEV_USERNAME = 4; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
10 |
var YK_SEC_ELEV_PASSWORD = 8; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
11 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
12 |
var yubikey_otp_current = false; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
13 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
14 |
function yk_mb_init(fieldid, statid) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
15 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
16 |
load_component(['messagebox', 'fadefilter', 'flyin', 'jquery', 'jquery-ui', 'l10n']); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
17 |
var mp = miniPrompt(yk_mb_construct); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
18 |
if ( typeof(fieldid) == 'function' ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
19 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
20 |
var input = mp.getElementsByTagName('input')[0]; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
21 |
input.submit_func = fieldid; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
22 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
23 |
else if ( fieldid && statid ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
24 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
25 |
var input = mp.getElementsByTagName('input')[0]; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
26 |
input.yk_field_id = fieldid; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
27 |
input.yk_status_id = statid; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
28 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
29 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
30 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
31 |
function yk_mb_construct(mp) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
32 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
33 |
mp.innerHTML = ''; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
34 |
mp.style.textAlign = 'center'; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
35 |
mp.innerHTML = '<h3>' + $lang.get('yubiauth_msg_please_touch_key') + '</h3>'; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
36 |
var progress = document.createElement('div'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
37 |
$(progress).addClass('yubikey_bar').css('text-align', 'left'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
38 |
var progimg = document.createElement('img'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
39 |
progimg.src = cdnPath + '/images/spacer.gif'; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
40 |
progress.appendChild(progimg); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
41 |
mp.appendChild(progress); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
42 |
var ta = document.createElement('input'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
43 |
ta.submitted = false; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
44 |
$(ta) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
45 |
.css('background-color', 'transparent') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
46 |
.css('border-width', '0px') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
47 |
.css('color', '#fff') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
48 |
.css('font-size', '1px') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
49 |
.css('padding', '0') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
50 |
.css('opacity', '0') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
51 |
.attr('size', '1') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
52 |
.keyup(function(e) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
53 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
54 |
if ( e.keyCode == 27 ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
55 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
56 |
window.clearInterval(yk_interval); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
57 |
miniPromptDestroy(this); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
58 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
59 |
// 0.3: submit only upon a keycode 13 |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
60 |
else if ( e.keyCode == 13 ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
61 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
62 |
this.submitted = true; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
63 |
yk_handle_submit(this); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
64 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
65 |
else |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
66 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
67 |
$('div.yubikey_bar > img', this.parentNode) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
68 |
.css('width', String(this.value.length * 2) + 'px') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
69 |
//.css('background-position', String((this.value.length > 44 ? 44 : this.value.length) - 44) + 'px -88px'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
70 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
71 |
e.preventDefault(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
72 |
e.stopPropagation(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
73 |
}); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
74 |
mp.appendChild(ta); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
75 |
setTimeout(function() |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
76 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
77 |
window.yk_interval = setInterval(function() |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
78 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
79 |
ta.focus(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
80 |
}, 50); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
81 |
}, 750); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
82 |
var info = document.createElement('p'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
83 |
$(info) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
84 |
.append('<span style="color: #ffffff; font-size: smaller;">' + $lang.get('yubiauth_msg_close_instructions') + '</span> ') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
85 |
.append('<a class="abutton abutton_green" href="#" onclick="miniPromptDestroy(this); return false;">' + $lang.get('etc_cancel') + '</a> ') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
86 |
//.append('<br />') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
87 |
.append('<span style="color: #909090; font-size: smaller;">' + $lang.get('yubiauth_msg_close_instructions') + '</span>') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
88 |
.css('margin-top', '0'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
89 |
mp.appendChild(info); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
90 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
91 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
92 |
function yk_handle_submit(ta) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
93 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
94 |
if ( ta.value.length > 44 || !ta.value.match(/^[cbdefghijklnrtuv]+$/) ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
95 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
96 |
// report "invalid characters" |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
97 |
setTimeout(function() |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
98 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
99 |
var parent = ta.parentNode; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
100 |
var tabackup = { |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
101 |
field_id: ta.yk_field_id, |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
102 |
status_id: ta.yk_status_id, |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
103 |
submit_func: ta.submit_func |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
104 |
}; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
105 |
yk_mb_construct(parent); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
106 |
var input = parent.getElementsByTagName('input')[0]; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
107 |
if ( tabackup.field_id ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
108 |
input.yk_field_id = tabackup.field_id; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
109 |
if ( tabackup.status_id ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
110 |
input.yk_status_id = tabackup.status_id; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
111 |
if ( tabackup.submit_func ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
112 |
input.submit_func = tabackup.submit_func; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
113 |
}, 1000); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
114 |
$('h3', ta.parentNode).text($lang.get(ta.value.length > 44 ? 'yubiauth_msg_too_long' : 'yubiauth_msg_invalid_chars')); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
115 |
$('div.yubikey_bar > img', this.parentNode).addClass('yubikey_bar_error'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
116 |
return false; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
117 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
118 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
119 |
window.clearInterval(yk_interval); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
120 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
121 |
if ( ta.yk_field_id && ta.yk_status_id ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
122 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
123 |
var field = document.getElementById(ta.yk_field_id); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
124 |
var status = document.getElementById(ta.yk_status_id); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
125 |
if ( $(status).hasClass('empty') || $(status).hasClass('rmpending') ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
126 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
127 |
$(status) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
128 |
.next('span.yubikey_pubkey') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
129 |
.text(ta.value.substr(0, 12)) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
130 |
.next('a.yubikey_enroll') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
131 |
.text($lang.get('yubiauth_ctl_btn_change_key')) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
132 |
.addClass('abutton_green') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
133 |
.after(' <a class="abutton abutton_red yubikey_enroll" href="#yk_clear" onclick="yk_clear(\'' + ta.yk_field_id + '\', \'' + ta.yk_status_id + '\'); return false;">' |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
134 |
+ $lang.get('yubiauth_ctl_btn_clear') + |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
135 |
'</a>'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
136 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
137 |
$(status).removeClass('empty').removeClass('enrolled').removeClass('rmpending').addClass('savepending').html($lang.get('yubiauth_ctl_status_enrolled_pending')); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
138 |
$(status).next('span.yubikey_pubkey').text(ta.value.substr(0, 12)); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
139 |
field.value = ta.value; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
140 |
miniPromptDestroy(ta); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
141 |
return true; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
142 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
143 |
else if ( ta.submit_func ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
144 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
145 |
ta.submit_func(ta); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
146 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
147 |
else |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
148 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
149 |
miniPromptDestroy(ta); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
150 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
151 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
152 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
153 |
function yk_login_validate_reqs(ta) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
154 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
155 |
$(ta.parentNode).remove('p'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
156 |
yubikey_otp_current = ta.value; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
157 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
158 |
miniPromptDestroy(ta, true); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
159 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
160 |
if ( logindata ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
161 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
162 |
if ( logindata.mb_object ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
163 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
164 |
// login window is open |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
165 |
if ( user_level == USER_LEVEL_GUEST ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
166 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
167 |
// for guests, get the user's yubikey auth flags |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
168 |
// we're still ok to submit, so make sure twofactor isn't enabled |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
169 |
// as we are a guest, we have to get the flags for the user from the server |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
170 |
var ajax = ajaxMakeXHR(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
171 |
var uri = makeUrlNS('Special', 'Yubikey', 'get_flags=' + ta.value.substr(0, 12)); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
172 |
var flags = 0; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
173 |
try |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
174 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
175 |
ajax.open('GET', uri, false); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
176 |
ajax.send(null); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
177 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
178 |
if ( ajax.readyState == 4 && ajax.status == 200 ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
179 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
180 |
// we got it |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
181 |
var response = String(ajax.responseText + ''); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
182 |
if ( check_json_response(response) ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
183 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
184 |
response = parseJSON(response); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
185 |
flags = response.flags || 0; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
186 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
187 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
188 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
189 |
catch ( e ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
190 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
191 |
ajaxLoginSetStatus(AJAX_STATUS_ERROR); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
192 |
return false; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
193 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
194 |
var show_username = flags & YK_SEC_NORMAL_USERNAME; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
195 |
var show_password = flags & YK_SEC_NORMAL_PASSWORD; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
196 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
197 |
else |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
198 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
199 |
var show_username = window.yk_user_flags & YK_SEC_ELEV_USERNAME; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
200 |
var show_password = window.yk_user_flags & YK_SEC_ELEV_PASSWORD; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
201 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
202 |
if ( !show_username ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
203 |
$('#ajax_login_field_username').parent('td').hide().prev().hide(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
204 |
if ( !show_password ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
205 |
$('#ajax_login_field_password').parent('td').hide().prev().hide(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
206 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
207 |
var can_submit = true; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
208 |
if ( show_username && !$('#ajax_login_field_username').attr('value') ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
209 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
210 |
$('#ajax_login_field_username').focus(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
211 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
212 |
if ( !show_password ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
213 |
$('#ajax_login_field_username').keyup(function(e) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
214 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
215 |
// assign press of Enter in username field to submit |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
216 |
if ( e.keyCode == 13 ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
217 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
218 |
$('#messageBoxButtons input:button:first').click(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
219 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
220 |
}); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
221 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
222 |
can_submit = false; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
223 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
224 |
if ( show_password && !$('#ajax_login_field_password').attr('value') ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
225 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
226 |
if ( can_submit ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
227 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
228 |
// can_submit only true if show_username false |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
229 |
$('#ajax_login_field_password').focus(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
230 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
231 |
can_submit = false; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
232 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
233 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
234 |
if ( can_submit ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
235 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
236 |
$('#messageBoxButtons input:button:first').click(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
237 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
238 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
239 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
240 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
241 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
242 |
function yk_clear(field_id, status_id) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
243 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
244 |
var field = document.getElementById(field_id); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
245 |
var status = document.getElementById(status_id); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
246 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
247 |
var was_pending = $(field).hasClass('wasempty'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
248 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
249 |
$(field).attr('value', ''); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
250 |
$(status) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
251 |
.removeClass('savepending') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
252 |
.removeClass('enrolled') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
253 |
.addClass( was_pending ? 'empty' : 'rmpending' ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
254 |
.text( was_pending ? $lang.get('yubiauth_ctl_status_empty') : $lang.get('yubiauth_ctl_status_remove_pending') ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
255 |
.next('span.yubikey_pubkey') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
256 |
.text('') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
257 |
.next('a') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
258 |
.text($lang.get('yubiauth_ctl_btn_enroll')) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
259 |
.removeClass('abutton_green') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
260 |
.next('a') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
261 |
.remove(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
262 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
263 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
264 |
addOnloadHook(function() |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
265 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
266 |
if ( is_iPhone ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
267 |
// kinda can't plug a yubikey into an iPhone |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
268 |
// ... yet? |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
269 |
return; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
270 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
271 |
attachHook('login_build_form', 'yk_login_dlg_hook(table, data);'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
272 |
attachHook('login_build_userinfo', 'if ( window.yubikey_otp_current ) userinfo.yubikey_otp = window.yubikey_otp_current;'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
273 |
if ( title == namespace_list.Special + 'Preferences/Yubikey' ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
274 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
275 |
load_component(['jquery', 'jquery-ui', 'expander']); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
276 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
277 |
}); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
278 |
|
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
279 |
function yk_login_dlg_hook(table, data) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
280 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
281 |
window.yubikey_otp_current = false; |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
282 |
var tr = document.createElement('tr'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
283 |
var td = document.createElement('td'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
284 |
$(td) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
285 |
.attr('colspan', '2') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
286 |
.css('text-align', 'center') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
287 |
.css('font-size', 'smaller') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
288 |
.css('font-weight', 'bold') |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
289 |
.html('<a href="#" onclick="yk_mb_init(yk_login_validate_reqs); return false;" style="color: #6fa202">' + $lang.get('yubiauth_btn_enter_otp') + '</a>'); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
290 |
$('a', td).blur(function(e) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
291 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
292 |
$('#messageBoxButtons input:button:first').focus(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
293 |
$('#ajax_login_field_captcha').focus(); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
294 |
}); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
295 |
if ( ( window.yk_reg_require_otp || window.yk_user_enabled ) && !data.locked_out.locked_out ) |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
296 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
297 |
setTimeout(function() |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
298 |
{ |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
299 |
yk_mb_init(yk_login_validate_reqs); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
300 |
}, 750); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
301 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
302 |
tr.appendChild(td); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
303 |
table.appendChild(tr); |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
304 |
} |
6212d849ab08
Move all files from plugins/ directory to the root
Dan Fuhry <dan@enanocms.org>
parents:
diff
changeset
|
305 |