From 56f4fc53aac82baef73a96f0e03d6d3427bd3356 Mon Sep 17 00:00:00 2001 From: Joshua Kiwiet-Pantaleoni Date: Wed, 7 Aug 2024 16:20:47 -0700 Subject: [PATCH] fix: mfa api token auth requires using authorize call, not checkSession MP-479 --- .../Settings/TwoStepVerification.vue | 68 ++++------ src/pages/ProcessBrowserAuth.vue | 37 ++---- src/util/KvAuth0.js | 124 ++++++++++++------ 3 files changed, 115 insertions(+), 114 deletions(-) diff --git a/src/components/Settings/TwoStepVerification.vue b/src/components/Settings/TwoStepVerification.vue index b16a02f095..0bcbad7bf8 100644 --- a/src/components/Settings/TwoStepVerification.vue +++ b/src/components/Settings/TwoStepVerification.vue @@ -49,14 +49,10 @@ import KvSettingsCard from '@/components/Kv/KvSettingsCard'; import KvLoadingPlaceholder from '~/@kiva/kv-components/vue/KvLoadingPlaceholder'; import KvButton from '~/@kiva/kv-components/vue/KvButton'; -const pageQuery = gql`query mfaQuery($mfa_token: String!) { +const pageQuery = gql`query mfaQuery { my { id - authenticatorEnrollments(mfa_token: $mfa_token) { - id - active - authenticator_type - } + enrolledInMFA } }`; @@ -85,45 +81,27 @@ export default { inject: ['apollo', 'kvAuth0'], mounted() { this.isLoading = true; - if (this.kvAuth0.enabled) { - this.kvAuth0.checkSession({ skipIfUserExists: true }) - .then(() => this.kvAuth0.getMfaManagementToken()) - .then(token => { - return this.apollo.query({ - query: pageQuery, - variables: { - mfa_token: token - } - }); - }) - .then(result => { - if (result.errors) { - throw result.errors; - } - const authEnrollments = result.data.my.authenticatorEnrollments; - for (let i = 0; i < authEnrollments.length; i += 1) { - if (authEnrollments[i].active === true) { - this.isMFAActive = true; - this.isLoading = false; - return; - } - } - this.isLoading = false; - }) - .catch(err => { - console.error(err); - this.$showTipMsg( - 'There was an error when getting your 2-step verification status. ' - + 'Please refresh the page and try again.', - 'error' - ); - try { - Sentry.captureException(err?.[0]?.extensions?.exception || err); - } catch (e) { - // no-op - } - }); - } + this.apollo.query({ + query: pageQuery, + }).then(result => { + if (result.errors) { + throw result.errors; + } + this.isMFAActive = result.data.my.enrolledInMFA || false; + this.isLoading = false; + }).catch(err => { + console.error(err); + this.$showTipMsg( + 'There was an error when getting your 2-step verification status. ' + + 'Please refresh the page and try again.', + 'error' + ); + try { + Sentry.captureException(err?.[0]?.extensions?.exception || err); + } catch (e) { + // no-op + } + }); } }; diff --git a/src/pages/ProcessBrowserAuth.vue b/src/pages/ProcessBrowserAuth.vue index b7fff13fbe..7a62563d20 100644 --- a/src/pages/ProcessBrowserAuth.vue +++ b/src/pages/ProcessBrowserAuth.vue @@ -5,42 +5,21 @@