This commit is contained in:
2021-03-11 19:33:41 +00:00
parent 66fcd9515d
commit b5b93d798e
2 changed files with 21 additions and 7 deletions

View File

@@ -197,7 +197,7 @@ todo: 2fa is going to be an absolute must have pretty soon, look into what's inv
User settings has a SECURITY section where control 2fa stuff
user chooses 2fa button to setup, a dialog pops up sends a request to server at which point a secret key for 2fa is generated and stored in the User account
and gets back the secret to display in a qr code on screen to searching
/auth/setup-hotp
/auth/setup-totp
user is redirected to a client form with the qr code displayed for teh secret
User gets QR code then displayed to sign up with auth software
User has to enter a valid code to save or enable 2fa fully otherwise it's not enabled if they cancel out

View File

@@ -4,10 +4,14 @@
<v-form ref="form">
<v-row>
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
tfaEnabled:{{ tfaEnabled }}
ui here if tfa enabled then only option is disable tfa if not enabled
then user sees code to scan into tfa app
<template v-if="tfaEnabled">
DISABLE TFA
</template>
<template v-else>
ENABLE TFA
<img alt="Embedded QR Code" :src="qCode" />
{{ obj.s }}
</template>
</v-row>
</v-form>
</v-col>
@@ -41,7 +45,14 @@ export default {
window.$gz.eventBus.$on("menu-click", clickHandler);
//fetch tfa secret and display here if tfa not enabled currently
console.log("tfaEnabled:", this.tfaEnabled);
if (!this.tfaEnabled) {
let res = await window.$gz.api.get("auth/totp");
if (res.error) {
throw new Error(res.error);
} else {
this.obj = res.data;
}
}
//------------------
} catch (err) {
@@ -67,7 +78,7 @@ export default {
data() {
return {
obj: {
s: null, // = u.HotpSecret,
s: null, // = u.TotpSecret,
qr: null // = qrCodeImageAsBase64
},
tfaEnabled: window.$gz.store.state.tfaEnabled,
@@ -107,6 +118,9 @@ export default {
computed: {
canSave: function() {
return this.formState.valid && this.formState.dirty;
},
qCode: function() {
return `data:image/png;base64,${this.obj.qr}`;
}
},
methods: {