4922 |
10 Aug 18 |
nicklas |
1 |
|
4922 |
10 Aug 18 |
nicklas |
var OTP = function() |
4922 |
10 Aug 18 |
nicklas |
3 |
{ |
4922 |
10 Aug 18 |
nicklas |
var otp = {}; |
4922 |
10 Aug 18 |
nicklas |
5 |
|
4922 |
10 Aug 18 |
nicklas |
otp.initPage = function() |
4922 |
10 Aug 18 |
nicklas |
7 |
{ |
4922 |
10 Aug 18 |
nicklas |
// Disable OTP fields on extended properties tab |
4922 |
10 Aug 18 |
nicklas |
Doc.element('ep.otpIsRequired.true').disabled = true; |
4922 |
10 Aug 18 |
nicklas |
Doc.element('ep.otpIsRequired.false').disabled = true; |
4922 |
10 Aug 18 |
nicklas |
11 |
|
4922 |
10 Aug 18 |
nicklas |
Events.addEventHandler('requireOtp.true', 'click', otp.copyOtpRequired); |
4922 |
10 Aug 18 |
nicklas |
Events.addEventHandler('requireOtp.false', 'click', otp.copyOtpRequired); |
4922 |
10 Aug 18 |
nicklas |
14 |
|
4922 |
10 Aug 18 |
nicklas |
Buttons.addClickHandler('btnOtpReset', otp.resetOtp); |
4922 |
10 Aug 18 |
nicklas |
16 |
} |
4922 |
10 Aug 18 |
nicklas |
17 |
|
4922 |
10 Aug 18 |
nicklas |
/* Copy 'OTP required' option to other places */ |
4922 |
10 Aug 18 |
nicklas |
otp.copyOtpRequired = function() |
4922 |
10 Aug 18 |
nicklas |
20 |
{ |
4922 |
10 Aug 18 |
nicklas |
// Radio buttons on the 'Additional info' tab |
4922 |
10 Aug 18 |
nicklas |
Doc.element('ep.otpIsRequired.true').checked = Doc.element('requireOtp.true').checked; |
4922 |
10 Aug 18 |
nicklas |
Doc.element('ep.otpIsRequired.false').checked = Doc.element('requireOtp.false').checked; |
4922 |
10 Aug 18 |
nicklas |
// This hidden element is the one that gets submitted to the server |
4922 |
10 Aug 18 |
nicklas |
Doc.element('otpIsRequired').value = Doc.element('requireOtp.true').checked; |
4922 |
10 Aug 18 |
nicklas |
26 |
} |
4922 |
10 Aug 18 |
nicklas |
27 |
|
4922 |
10 Aug 18 |
nicklas |
otp.resetOtp = function() |
4922 |
10 Aug 18 |
nicklas |
29 |
{ |
4922 |
10 Aug 18 |
nicklas |
var frm = document.forms['user']; |
4922 |
10 Aug 18 |
nicklas |
if (!frm['ep.otpSecretKey']) |
4922 |
10 Aug 18 |
nicklas |
32 |
{ |
4922 |
10 Aug 18 |
nicklas |
// We need to create this with an empty value to reset the secret key |
4922 |
10 Aug 18 |
nicklas |
Forms.addHidden(frm, 'ep.otpSecretKey', ''); |
4922 |
10 Aug 18 |
nicklas |
35 |
} |
4922 |
10 Aug 18 |
nicklas |
Doc.hide('has-otp'); |
4922 |
10 Aug 18 |
nicklas |
Doc.show('otp-was-reset'); |
4922 |
10 Aug 18 |
nicklas |
Doc.show('require-otp-row'); |
4922 |
10 Aug 18 |
nicklas |
39 |
} |
4922 |
10 Aug 18 |
nicklas |
40 |
|
4922 |
10 Aug 18 |
nicklas |
return otp; |
4922 |
10 Aug 18 |
nicklas |
42 |
}(); |
4922 |
10 Aug 18 |
nicklas |
43 |
|
4922 |
10 Aug 18 |
nicklas |
Doc.onLoad(OTP.initPage); |
4922 |
10 Aug 18 |
nicklas |
45 |
|