Skip to content

Commit

Permalink
chore: update site to show window
Browse files Browse the repository at this point in the history
  • Loading branch information
yeojz committed Apr 21, 2018
1 parent 28a24b7 commit 8af85d9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions site/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
var step = 30;
var timing;

otplib.authenticator.options = {
window: 1
};

function toggleTabs(evt) {
document.querySelectorAll('.tab-item').forEach(function(tab) {
tab.classList.remove('is-active');
Expand Down Expand Up @@ -75,21 +79,23 @@
.querySelector('.otp-verify-send')
.addEventListener('click', function() {
var inputValue = document.querySelector('.otp-verify-input').value;
var isValid = otplib.authenticator.check(inputValue, secret);
var delta = otplib.authenticator.checkDelta(inputValue, secret);

var text = document.querySelector('.otp-verify-result .text');
var icon = document.querySelector('.otp-verify-result .fa');

if (isValid) {
var win = '<br /> (window: ' + delta + ')';

if (Number.isInteger(delta)) {
icon.classList.add('fa-check');
icon.classList.remove('fa-times');
text.innerHTML = 'Verified token';
text.innerHTML = 'Verified token' + win;
return;
}

icon.classList.add('fa-times');
icon.classList.remove('fa-check');
text.innerHTML = 'Cannot verify token.';
text.innerHTML = 'Cannot verify token';
});
}

Expand Down

0 comments on commit 8af85d9

Please sign in to comment.