From 40efcf1de8c0e3558a7801dcbeff1532d12846a8 Mon Sep 17 00:00:00 2001 From: Tyler Date: Tue, 29 Sep 2020 12:00:58 -0400 Subject: [PATCH] fix: login and sign up stuff --- src/_pages/Layout.vue | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/_pages/Layout.vue b/src/_pages/Layout.vue index 10215a1..58ac79e 100644 --- a/src/_pages/Layout.vue +++ b/src/_pages/Layout.vue @@ -59,6 +59,7 @@ export default { ...mapActions('paymentMethods', ['getAllAccountPaymentMethods']), initDefaults() { + this.currentUser = util.currentUser(); const selectedLocale = this.currentUser !== null && typeof this.currentUser.locale !== 'undefined' && @@ -82,6 +83,14 @@ export default { (!this.configs.paymentsEnabled || this.hasPaymentMethod === true || this.$route.path === '/payment')); + + console.log( + 'initDefaults', + !this.currentUser, + this.$route.path, + !!this.verifiedContacts, + this.currentUser && !!this.currentUser.admin + ); }, hasVerifiedContact(policy) { @@ -120,20 +129,15 @@ export default { watch: { $route() { - this.isPageAvailable = - !this.currentUser || - this.$route.path === '/me/action' || - this.$route.path === '/logout' || - this.$route.path === '/verifyEmail' || - ((this.verifiedContacts || this.currentUser.admin) && - (!this.configs.paymentsEnabled || - this.hasPaymentMethod === true || - this.$route.path === '/payment')); + this.$nextTick(() => { + this.initDefaults(); + }); }, policy(p) { this.verifiedContacts = this.hasVerifiedContact(p); const currentUser = util.currentUser(); + if (!currentUser) return; if (!this.verifiedContacts && !currentUser.admin) { this.navigateToVerifyEmail(); if (this.verifiedContactRefresher === null) { @@ -162,7 +166,11 @@ export default { }, accountPaymentMethods(pms, oldpms) { - if (pms && this.configs.paymentsEnabled) { + if ( + pms && + this.configs.paymentsEnabled && + (this.verifiedContacts || (this.currentUser && this.currentUser.admin)) + ) { const payMethods = []; for (let i = 0; i < pms.length; i++) { const pm = pms[i];