From b5b93d798e887cf705c079f8600aaf45b1f870e3 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 11 Mar 2021 19:33:41 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 2 +- ayanova/src/views/home-security.vue | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 0e1ef999..9b2ae2d7 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -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 diff --git a/ayanova/src/views/home-security.vue b/ayanova/src/views/home-security.vue index d402ef9c..4c8d4543 100644 --- a/ayanova/src/views/home-security.vue +++ b/ayanova/src/views/home-security.vue @@ -4,10 +4,14 @@ - 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 + + @@ -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: {