Skip to content

Commit 349d3c2

Browse files
committed
fix(ui): totp qr code url
1 parent dd20b48 commit 349d3c2

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

web/src/components/UserForm.vue

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
</v-form>
108108
</v-tab-item>
109109

110-
<v-tab-item key="2fa" class="pb-4" v-if="item != null">
110+
<v-tab-item key="2fa" v-if="item != null">
111111

112112
<div v-if="!isNew">
113113
<div class="title mb-3">Password</div>
@@ -188,25 +188,12 @@ export default {
188188
return {
189189
passwordDialog: null,
190190
totpEnabled: false,
191+
totpQrUrl: null,
192+
191193
tab: null,
192194
};
193195
},
194196
195-
computed: {
196-
totpQrUrl() {
197-
if (!this.totpEnabled || this.item == null || this.item.totp == null) {
198-
return null;
199-
}
200-
201-
let baseURI = document.baseURI;
202-
if (baseURI.endsWith('/')) {
203-
baseURI = baseURI.substring(0, baseURI.length - 1);
204-
}
205-
206-
return `${baseURI}/api/users/${this.itemId}/2fas/totp/${this.item.totp.id}/qr`;
207-
},
208-
},
209-
210197
watch: {
211198
tab(value) {
212199
if (value === 0) {
@@ -224,6 +211,13 @@ export default {
224211
url: `/api/users/${this.itemId}/2fas/totp`,
225212
responseType: 'json',
226213
})).data;
214+
215+
// let baseURI = document.baseURI;
216+
// if (baseURI.endsWith('/')) {
217+
// baseURI = baseURI.substring(0, baseURI.length - 1);
218+
// }
219+
220+
this.totpQrUrl = `${document.baseURI}api/users/${this.itemId}/2fas/totp/${this.item.totp.id}/qr`;
227221
}
228222
} else if (this.item.totp != null) {
229223
await axios({
@@ -232,13 +226,20 @@ export default {
232226
responseType: 'json',
233227
});
234228
this.item.totp = null;
229+
this.totpQrUrl = null;
235230
}
236231
},
237232
},
238233
239234
methods: {
240235
afterLoadData() {
241-
this.totpEnabled = this.item.totp != null;
236+
if (this.item.totp == null) {
237+
this.totpEnabled = false;
238+
this.totpQrUrl = null;
239+
} else {
240+
this.totpEnabled = true;
241+
this.totpQrUrl = `${document.baseURI}api/users/${this.itemId}/2fas/totp/${this.item.totp.id}/qr`;
242+
}
242243
},
243244
244245
async copyToClipboard(text) {

0 commit comments

Comments
 (0)