Skip to content

Commit

Permalink
fix(ui): link to totp qr code
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftin committed Feb 10, 2025
1 parent 1a65fe8 commit dd20b48
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions web/src/components/UserForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,25 @@ export default {
return {
passwordDialog: null,
totpEnabled: false,
totpQrUrl: null,
tab: null,
};
},
computed: {
totpQrUrl() {
if (!this.totpEnabled || this.item == null || this.item.totp == null) {
return null;
}
let baseURI = document.baseURI;
if (baseURI.endsWith('/')) {
baseURI = baseURI.substring(0, baseURI.length - 1);
}
return `${baseURI}/api/users/${this.itemId}/2fas/totp/${this.item.totp.id}/qr`;
},
},
watch: {
tab(value) {
if (value === 0) {
Expand All @@ -211,7 +224,6 @@ export default {
url: `/api/users/${this.itemId}/2fas/totp`,
responseType: 'json',
})).data;
this.totpQrUrl = `/api/users/${this.itemId}/2fas/totp/${this.item.totp.id}/qr`;
}
} else if (this.item.totp != null) {
await axios({
Expand All @@ -220,20 +232,13 @@ export default {
responseType: 'json',
});
this.item.totp = null;
this.totpQrUrl = null;
}
},
},
methods: {
afterLoadData() {
if (this.item.totp == null) {
this.totpEnabled = false;
this.totpQrUrl = null;
} else {
this.totpEnabled = true;
this.totpQrUrl = `/api/users/${this.itemId}/2fas/totp/${this.item.totp.id}/qr`;
}
this.totpEnabled = this.item.totp != null;
},
async copyToClipboard(text) {
Expand Down

0 comments on commit dd20b48

Please sign in to comment.