From 078dafb766bf994df1fcf649e5a9462efce2ea62 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Fri, 10 Jan 2020 23:30:38 +0100 Subject: [PATCH] Display properly OTP with more/less than 6 digits --- resources/js/components/OneTimePassword.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/js/components/OneTimePassword.vue b/resources/js/components/OneTimePassword.vue index b56e3b63..68acea6e 100644 --- a/resources/js/components/OneTimePassword.vue +++ b/resources/js/components/OneTimePassword.vue @@ -18,6 +18,7 @@ AccountId : null } }, + methods: { getOTP: function () { @@ -27,7 +28,9 @@ axios.defaults.headers.common['Authorization'] = 'Bearer ' + token axios.get('api/twofaccounts/' + this.AccountId + '/totp').then(response => { - this.totp = response.data.totp.substr(0, 3) + " " + response.data.totp.substr(3); + let spacePosition = Math.ceil(response.data.totp.length / 2); + + this.totp = response.data.totp.substr(0, spacePosition) + " " + response.data.totp.substr(spacePosition); this.position = response.data.position; let dots = this.$el.querySelector('.dots');