From 221da67bea65e17631bbe0ad582a8f60fcb42d7b Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Tue, 11 Jun 2024 09:49:39 +0300 Subject: [PATCH] Update token immediately when values change --- public/js/app.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 74171d2..1a0fd5c 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -34,7 +34,6 @@ const app = Vue.createApp({ period: 30, algorithm: 'SHA1', updatingIn: 30, - token: null, clipboardButton: null, }; }, @@ -54,20 +53,21 @@ const app = Vue.createApp({ }, computed: { - totp: function () { - return new OTPAuth.TOTP({ + token: function () { + const totp = new OTPAuth.TOTP({ algorithm: this.algorithm, digits: this.digits, period: this.period, secret: OTPAuth.Secret.fromBase32(stripSpaces(this.secret_key)), }); - } + return truncateTo(totp.generate(), this.digits); + }, }, methods: { update: function () { this.updatingIn = this.period - (getCurrentSeconds() % this.period); - this.token = truncateTo(this.totp.generate(), this.digits); + this.$forceUpdate(); }, getKeyFromUrl: function () {