Skip to content

fix: reduce auth hydration and stabilize signup#3591

Open
marcusgrando wants to merge 12 commits into
devfrom
grando/fix-login-hydration
Open

fix: reduce auth hydration and stabilize signup#3591
marcusgrando wants to merge 12 commits into
devfrom
grando/fix-login-hydration

Conversation

@marcusgrando
Copy link
Copy Markdown
Member

@marcusgrando marcusgrando commented Jun 3, 2026

Bug fix

What was the problem?

Login restored the account session with extra blocking calls in the critical path:

  • sign-in analytics hydrated account/user data before switchAccount, duplicating /api/account/info and /api/user/me.
  • account guard loaded /api/v3/contract/{clientId}/products through loadAccountHydration.
  • account guard also loaded /edge_api/v4/service_orders only to derive the plan gate, even though /api/account/info already returns has_service_order_plan.

In the HAR, Contract took about 2.09s and Service Orders took about 2.93s after the duplicated account hydration.

Email sign-up had a separate issue: after the account was created, a post-success analytics tracking error could keep the UI on the sign-up form instead of showing the activation step. This left the user with a created but inactive account, which then produced User not activated. on login until activation was completed.

The post-activation paid plan step could also surface Stripe raw errors such as No such checkout.session when Stripe rejected a checkout session during confirmation. That request is made inside Stripe.js, so it may not show as a regular Console API request in DevTools.

Reviews also found that the has_service_order_plan dependency was only implicit via response spread, SSO sign-in analytics could be skipped if the verify payload missed user_tracking_info, and a few comments/returned loading refs were stale after the login changes.

Expected behavior

Login should restore the session and decide onboarding redirects without waiting for Contract or Service Orders product calls. Contract plan data should still load where it is actually used, such as Billing and Copilot.

has_service_order_plan from /api/account/info is the source of truth for the post-login plan gate: false opens plan configuration, true skips the plan screen and logs the user into Console. The account adapter should expose that dependency explicitly and default missing/non-boolean values to false.

SSO sign-in analytics should still attempt tracking for successful non-first-login SSO redirects even when token tracking data is absent, using store data fallback.

Email sign-up should show the activation instructions after successful account creation, even if analytics tracking fails.

The paid plan checkout should refresh stale Stripe sessions instead of showing raw Stripe session identifiers to the user.

How was it solved

  • Reused token/verify.user_tracking_info for email, MFA, and SSO sign-in tracking instead of pre-switch account hydration.
  • Kept SSO sign-in tracking from being gated on user_tracking_info presence, while still avoiding tracking failed redirects back to /login.
  • Kept contract plan loading out of loadAccountHydration; Billing and Copilot still lazy-load it with loadContractData.
  • Made account.has_service_order_plan the authoritative store getter for the onboarding gate.
  • Mapped account info has_service_order_plan explicitly in the V2 account adapter with a strict boolean default.
  • Removed the duplicate hasActivePlan state and the setHasActivePlan hydration side effect.
  • Removed ensureServiceOrdersList() from accountGuard, so Service Orders no longer blocks initial login navigation.
  • Cleaned stale plan-gate comments and unused drawer loading refs.
  • Made email sign-up success tracking non-blocking so account activation UI still appears after a successful /signup response.
  • Reused the existing stale checkout-session recovery path when Stripe rejects the session during signup plan submission.
  • Updated tests for account adapter mapping, account hydration, account store plan gate behavior, sign-in tracking, account guard behavior, sign-up activation after tracking failures, and stale checkout-session recovery.

How to test

  • ./node_modules/.bin/eslint src/services/v2/account/account-service.js src/tests/services/v2/account/account-service.test.js src/tests/helpers/account-data.test.js src/tests/stores/account.test.js --no-fix --ignore-path .gitignore
  • ./node_modules/.bin/vitest run src/tests/services/v2/account/account-service.test.js src/tests/helpers/account-data.test.js src/tests/stores/account.test.js
  • ./node_modules/.bin/eslint src/router/routes/switch-account-routes/index.js src/router/hooks/guards/accountGuard.js src/helpers/account-data.js src/composables/useEdgeApplicationV3CreateService.js src/composables/useWorkloadDomainDrawerServices.js src/tests/helpers/track-auth-event.test.js --no-fix --ignore-path .gitignore
  • ./node_modules/.bin/eslint src/router/hooks/guards/accountGuard.js --no-fix --no-ignore --ignore-path .gitignore
  • ./node_modules/.bin/vitest run src/tests/helpers/track-auth-event.test.js src/tests/router/hooks/guards/account-guard.test.js
  • ./node_modules/.bin/eslint src/helpers/account-data.js src/stores/account.js src/tests/helpers/account-data.test.js src/tests/stores/account.test.js src/tests/router/hooks/guards/account-guard.test.js --no-fix --ignore-path .gitignore
  • ./node_modules/.bin/eslint src/tests/router/hooks/guards/account-guard.test.js --no-fix --no-ignore --ignore-path .gitignore
  • env TMPDIR=/Users/marcus.grando/git/azion-console-kit/.tmp YARN_GLOBAL_FOLDER=/Users/marcus.grando/git/azion-console-kit/.yarn-global yarn --cache-folder .yarn-cache vitest run src/tests/helpers/account-data.test.js src/tests/stores/account.test.js src/tests/router/hooks/guards/account-guard.test.js
  • ./node_modules/.bin/vitest run src/tests/helpers/account-data.test.js src/tests/router/hooks/guards/account-guard.test.js src/tests/helpers/track-auth-event.test.js src/tests/helpers/account-handler-switch-broadcast.test.js src/tests/helpers/account-handler-has-session.test.js src/tests/services/auth-services/verify-authentication-service.test.js src/tests/plugins/analytics/trackers/SignInTracker.test.js
  • ./node_modules/.bin/eslint src/templates/signup-block/login-with-email-block.vue src/tests/templates/login-with-email-block.test.js src/services/signup-services/signup-service.js src/tests/services/signup-services/signup-service.test.js src/templates/signup-block/form-signup-block.vue src/templates/signup-block/account-activation.vue
  • ./node_modules/.bin/vitest run src/tests/templates/login-with-email-block.test.js src/tests/services/signup-services/signup-service.test.js src/tests/views/signup-additional-data-view.test.js
  • ./node_modules/.bin/eslint src/templates/checkout-block/checkout-plan-block.vue src/templates/checkout-block/payment-method-block.vue src/templates/checkout-block/helpers/stripe-error-mapper.js src/tests/templates/checkout-plan-block.test.js src/tests/templates/payment-method-block.test.js src/views/Signup/AdditionalDataView.vue
  • ./node_modules/.bin/vitest run src/tests/templates/checkout-plan-block.test.js src/tests/templates/payment-method-block.test.js src/tests/views/signup-additional-data-view.test.js src/tests/composables/useCheckoutSessionPreparer.test.js src/tests/templates/pricing-calculation-block.test.js
  • git diff --check

Remove account hydration from pre-switch sign-in tracking and reuse token verification tracking metadata to avoid duplicate account/profile requests during login.

Derive active plan state from account info so the account guard no longer blocks login on contract or service order product calls; Billing and Copilot still lazy-load contract plan data.
@marcusgrando marcusgrando force-pushed the grando/fix-login-hydration branch from e18b848 to 958fb2f Compare June 3, 2026 23:21
@marcusgrando marcusgrando changed the title fix: reduce login hydration calls fix: remove login-blocking hydration calls Jun 3, 2026
marcusgrando and others added 2 commits June 3, 2026 20:24
Install git before security checkout, fetch the PR base branch for architecture governance, and run the security linter only against changed files so legacy findings outside the PR do not block the login hydration fix.
@marcusgrando marcusgrando force-pushed the grando/fix-login-hydration branch from 8a2cca7 to 258006a Compare June 4, 2026 00:06
@marcusgrando marcusgrando marked this pull request as draft June 4, 2026 00:48
Handle non-API signup errors without throwing inside the catch block, always clear the loading state, and cover the recaptcha failure path before the signup request is sent.
Keep successful email signup on the activation flow even if analytics tracking fails after account creation.

This prevents a created but inactive account from leaving the user on the signup form without the activation instructions.
@marcusgrando marcusgrando changed the title fix: remove login-blocking hydration calls fix: reduce auth hydration and stabilize signup Jun 4, 2026
Detect stale Stripe checkout session errors during signup plan submission and reuse the existing recovery path instead of showing the raw Stripe message.

This refreshes the checkout session when confirmation rejects a consumed, expired, or environment-mismatched session.
Remove Vue compiler macro imports from drawer components so local startup no longer reports defineExpose import warnings.

The macro calls stay in place because Vue exposes them through the compiler.
Move legacy drawer service calls behind Vue Query composables so the defineExpose cleanup does not expose direct service imports to the changed-file architecture gate.

This keeps existing drawer contracts while satisfying the TanStack governance check in CI.
Harden signup activation after navigation failures, make security changed-file lint resilient to zero or orphan base refs, and keep security lint scoped to security rules. Also tighten plan entitlement input handling and remove stale tracking fallback code.
Use has_service_order_plan from account info as the authoritative source for the post-login plan gate. Remove the duplicate hasActivePlan state, keep hydration free of Contract/service-order fallback, and cover true/false/non-boolean behavior in focused tests.
@marcusgrando marcusgrando marked this pull request as ready for review June 5, 2026 14:37
Keep SSO sign-in analytics from depending on token tracking payload presence, while avoiding tracking failed redirects back to login. Clean stale plan-gate comments and remove unused drawer loading returns surfaced by review.
Normalize has_service_order_plan in the account info adapter so the onboarding gate depends on a visible boolean contract instead of an implicit spread. Default missing or non-boolean backend values to false and cover the adapter behavior with focused tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant