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 {
188188 return {
189189 passwordDialog: null ,
190190 totpEnabled: false ,
191- totpQrUrl: null ,
192-
193191 tab: null ,
194192 };
195193 },
196194
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+
197210 watch: {
198211 tab (value ) {
199212 if (value === 0 ) {
@@ -211,7 +224,6 @@ export default {
211224 url: ` /api/users/${ this .itemId } /2fas/totp` ,
212225 responseType: ' json' ,
213226 })).data ;
214- this .totpQrUrl = ` /api/users/${ this .itemId } /2fas/totp/${ this .item .totp .id } /qr` ;
215227 }
216228 } else if (this .item .totp != null ) {
217229 await axios ({
@@ -220,20 +232,13 @@ export default {
220232 responseType: ' json' ,
221233 });
222234 this .item .totp = null ;
223- this .totpQrUrl = null ;
224235 }
225236 },
226237 },
227238
228239 methods: {
229240 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 ;
237242 },
238243
239244 async copyToClipboard (text ) {
You can’t perform that action at this time.
0 commit comments