Fix #85, #86 - Unwanted base32 operation on secret cause invalid otp

This commit is contained in:
Bubka 2022-05-31 23:20:56 +02:00
parent 4997562c45
commit 75860686f7
3 changed files with 9 additions and 9 deletions

View File

@ -52,7 +52,6 @@
counter : null,
image : String,
qrcode : null,
secretIsBase32Encoded : Number,
uri : String
},

View File

@ -87,7 +87,7 @@
<div class="field has-addons">
<p class="control">
<span class="select">
<select @change="form.secret=''" v-model="form.secretIsBase32Encoded">
<select @change="form.secret=''" v-model="secretIsBase32Encoded">
<option v-for="format in secretFormats" :value="format.value">{{ format.text }}</option>
</select>
</span>
@ -187,13 +187,13 @@
showAlternatives : false,
tempIcon: '',
uri: '',
secretIsBase32Encoded: 0,
form: new Form({
service: '',
account: '',
otp_type: '',
icon: '',
secret: '',
secretIsBase32Encoded: 0,
algorithm: '',
digits: null,
counter: null,
@ -241,6 +241,7 @@
this.axios.post('/api/v1/twofaccounts/preview', { uri: this.uri }).then(response => {
this.form.fill(response.data)
this.secretIsBase32Encoded = 1
this.tempIcon = response.data.icon ? response.data.icon : null
this.showQuickForm = true
})
@ -277,7 +278,7 @@
this.form.icon = this.tempIcon
// Secret to base32 if necessary
this.form.secret = this.form.secretIsBase32Encoded ? this.form.secret : Base32.encode(this.form.secret).toString();
this.form.secret = this.secretIsBase32Encoded ? this.form.secret : Base32.encode(this.form.secret).toString();
await this.form.post('/api/v1/twofaccounts')
@ -318,7 +319,7 @@
// Then the otp described by the uri
this.axios.post('/api/v1/twofaccounts/preview', { uri: data.data }).then(response => {
this.form.fill(response.data)
this.form.secretIsBase32Encoded = 1
this.secretIsBase32Encoded = 1
this.tempIcon = response.data.icon ? response.data.icon : null
})
.catch(error => {

View File

@ -33,7 +33,7 @@
<div class="field has-addons">
<p class="control">
<span class="select">
<select @change="form.secret=''" v-model="form.secretIsBase32Encoded">
<select @change="form.secret=''" v-model="secretIsBase32Encoded">
<option v-for="format in secretFormats" :value="format.value">{{ format.text }}</option>
</select>
</span>
@ -133,6 +133,7 @@
counterIsLocked: true,
twofaccountExists: false,
tempIcon: '',
secretIsBase32Encoded: null,
form: new Form({
service: '',
account: '',
@ -140,7 +141,6 @@
uri: '',
icon: '',
secret: '',
secretIsBase32Encoded: null,
algorithm: '',
digits: null,
counter: null,
@ -196,7 +196,7 @@
const { data } = await this.axios.get('/api/v1/twofaccounts/' + this.$route.params.twofaccountId)
this.form.fill(data)
this.form.secretIsBase32Encoded = 1
this.secretIsBase32Encoded = 1
this.twofaccountExists = true
// set account icon as temp icon
@ -218,7 +218,7 @@
}
// Secret to base32 if necessary
this.form.secret = this.form.secretIsBase32Encoded ? this.form.secret : Base32.encode(this.form.secret).toString();
this.form.secret = this.secretIsBase32Encoded ? this.form.secret : Base32.encode(this.form.secret).toString();
await this.form.put('/api/v1/twofaccounts/' + this.$route.params.twofaccountId)