Browse Source

Display properly OTP with more/less than 6 digits

Bubka 5 years ago
parent
commit
078dafb766
1 changed files with 4 additions and 1 deletions
  1. 4 1
      resources/js/components/OneTimePassword.vue

+ 4 - 1
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');