diff --git a/components/account/activation/AccountActivate.vue b/components/account/activation/AccountActivate.vue index e66b3a54..43561f3f 100644 --- a/components/account/activation/AccountActivate.vue +++ b/components/account/activation/AccountActivate.vue @@ -10,7 +10,9 @@ const { uid, token } = route.params; const validating = ref(true); const isValid = ref(false); -const { getAccount } = useMainStore(); +const mainStore = useMainStore(); +const { getAccount } = mainStore; +const { account } = storeToRefs(mainStore); const logger = useLogger(); async function validateToken() { @@ -33,6 +35,22 @@ onBeforeMount(async () => { await getAccount(); }); const { t } = useI18n(); + +const { getLastRedirectUrl } = useRedirectUrl(); + +const lastPaymentLink = computed(() => { + const accountVal = get(account); + if (accountVal && accountVal.username) + return getLastRedirectUrl(accountVal.username); + + return undefined; +}); + +function redirectToPaymentLink() { + const paymentLink = get(lastPaymentLink); + if (paymentLink) + window.location.href = paymentLink; +} @@ -224,6 +225,7 @@ const { t } = useI18n(); color="primary" class="w-full" size="lg" + type="submit" :loading="loading" @click="finish()" > diff --git a/components/account/signup/SignupCustomerInformation.vue b/components/account/signup/SignupCustomerInformation.vue index 56171508..649bfb68 100644 --- a/components/account/signup/SignupCustomerInformation.vue +++ b/components/account/signup/SignupCustomerInformation.vue @@ -54,83 +54,87 @@ const { t } = useI18n(); diff --git a/components/account/signup/SignupForm.vue b/components/account/signup/SignupForm.vue index 47fcf062..c36fe2e4 100644 --- a/components/account/signup/SignupForm.vue +++ b/components/account/signup/SignupForm.vue @@ -2,6 +2,7 @@ import { get, set } from '@vueuse/core'; import { FetchError } from 'ofetch'; import { fetchWithCsrf } from '~/utils/api'; +import { useRedirectUrl } from '~/composables/redirect-url'; import type { SignupAccountPayload, SignupAddressPayload, @@ -39,6 +40,10 @@ const addressForm = ref({ const loading = ref(false); const externalResults = ref({}); +const route = useRoute(); + +const { saveRedirectUrl } = useRedirectUrl(); + async function signup({ recaptchaToken, }: { @@ -64,6 +69,10 @@ async function signup({ }, }); if (result) { + const { redirectUrl } = route.query; + if (redirectUrl) + saveRedirectUrl(payload.username, decodeURIComponent(redirectUrl as string)); + await navigateTo({ path: '/activation' }); } else if (typeof message === 'object') { diff --git a/components/checkout/payment-method/PaymentMethodSelection.vue b/components/checkout/payment-method/PaymentMethodSelection.vue index 6f0bee61..81c8fe0a 100644 --- a/components/checkout/payment-method/PaymentMethodSelection.vue +++ b/components/checkout/payment-method/PaymentMethodSelection.vue @@ -26,7 +26,6 @@ const { paymentMethodId } = usePaymentMethodParam(); const { identifier } = toRefs(props); const { authenticated } = storeToRefs(store); -const loginRequired = ref(false); const method = ref(get(paymentMethodId)); const processing = ref(false); @@ -65,39 +64,42 @@ async function back() { }); } +const router = useRouter(); + async function next() { - if (get(authenticated)) { - set(processing, true); - const selectedMethod = get(selected); - assert(selectedMethod); - const { name, id: method } = selectedMethod; + set(processing, true); + const selectedMethod = get(selected); + assert(selectedMethod); + const { name, id: method } = selectedMethod; + + const { href } = router.resolve({ + name, + query: { + plan: get(plan), + id: get(identifier), + method, + }, + }); + if (get(authenticated)) { if (method === PaymentMethod.CARD) { // For card payments we use href instead of router to trigger a server reload // This need to happen due to the CSP policy required for 3DSecure v2 - const queryString = new URLSearchParams({ - plan: get(plan).toString(), - id: get(identifier) ?? '', - method: method.toString(), - }); - const url = new URL( - `${window.location.origin}/checkout/pay/card?${queryString}`, - ); - window.location.href = url.toString(); + window.location.href = new URL( + `${window.location.origin}${href}`, + ).toString(); } else { - await navigateTo({ - name, - query: { - plan: get(plan), - id: get(identifier), - method, - }, - }); + await navigateTo(href); } } else { - set(loginRequired, true); + await navigateTo({ + path: '/login', + query: { + redirectUrl: encodeURIComponent(href), + }, + }); } } @@ -152,7 +154,6 @@ function select(m: PaymentMethod) { {{ t('actions.continue') }} - diff --git a/components/integration/IntegrationDetails.vue b/components/integration/IntegrationDetails.vue index 0317b4f6..cff97950 100644 --- a/components/integration/IntegrationDetails.vue +++ b/components/integration/IntegrationDetails.vue @@ -110,10 +110,11 @@ const { isMdAndUp } = useBreakpoint(); leave-to-class="opacity-0" class="flex-1 flex flex-col gap-10" > - +
+ +