File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -188,12 +188,25 @@ export default {
188
188
return {
189
189
passwordDialog: null ,
190
190
totpEnabled: false ,
191
- totpQrUrl: null ,
192
-
193
191
tab: null ,
194
192
};
195
193
},
196
194
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
+
197
210
watch: {
198
211
tab (value ) {
199
212
if (value === 0 ) {
@@ -211,7 +224,6 @@ export default {
211
224
url: ` /api/users/${ this .itemId } /2fas/totp` ,
212
225
responseType: ' json' ,
213
226
})).data ;
214
- this .totpQrUrl = ` /api/users/${ this .itemId } /2fas/totp/${ this .item .totp .id } /qr` ;
215
227
}
216
228
} else if (this .item .totp != null ) {
217
229
await axios ({
@@ -220,20 +232,13 @@ export default {
220
232
responseType: ' json' ,
221
233
});
222
234
this .item .totp = null ;
223
- this .totpQrUrl = null ;
224
235
}
225
236
},
226
237
},
227
238
228
239
methods: {
229
240
afterLoadData () {
230
- if (this .item .totp == null ) {
231
- this .totpEnabled = false ;
232
- this .totpQrUrl = null ;
233
- } else {
234
- this .totpEnabled = true ;
235
- this .totpQrUrl = ` /api/users/${ this .itemId } /2fas/totp/${ this .item .totp .id } /qr` ;
236
- }
241
+ this .totpEnabled = this .item .totp != null ;
237
242
},
238
243
239
244
async copyToClipboard (text ) {
You can’t perform that action at this time.
0 commit comments