Fix onboarding process not getting the subcription plan
This commit is contained in:
@@ -111,7 +111,33 @@ class EnhancedAuthService:
|
||||
|
||||
# Commit transaction
|
||||
await uow.commit()
|
||||
|
||||
|
||||
# Store subscription plan selection in onboarding progress for later retrieval
|
||||
if user_data.subscription_plan or user_data.use_trial or user_data.payment_method_id:
|
||||
try:
|
||||
from app.repositories.onboarding_repository import OnboardingRepository
|
||||
from app.models.onboarding import UserOnboardingProgress
|
||||
|
||||
onboarding_repo = OnboardingRepository(db_session)
|
||||
plan_data = {
|
||||
"subscription_plan": user_data.subscription_plan or "starter",
|
||||
"use_trial": user_data.use_trial or False,
|
||||
"payment_method_id": user_data.payment_method_id,
|
||||
"saved_at": datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
|
||||
await onboarding_repo.save_step_data(
|
||||
str(new_user.id),
|
||||
"user_registered",
|
||||
plan_data
|
||||
)
|
||||
|
||||
logger.info("Subscription plan saved to onboarding progress",
|
||||
user_id=new_user.id,
|
||||
plan=user_data.subscription_plan)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to save subscription plan to onboarding progress", error=str(e))
|
||||
|
||||
# Publish registration event (non-blocking)
|
||||
try:
|
||||
await publish_user_registered({
|
||||
@@ -119,7 +145,8 @@ class EnhancedAuthService:
|
||||
"email": new_user.email,
|
||||
"full_name": new_user.full_name,
|
||||
"role": new_user.role,
|
||||
"registered_at": datetime.now(timezone.utc).isoformat()
|
||||
"registered_at": datetime.now(timezone.utc).isoformat(),
|
||||
"subscription_plan": user_data.subscription_plan or "starter"
|
||||
})
|
||||
except Exception as e:
|
||||
logger.warning("Failed to publish registration event", error=str(e))
|
||||
|
||||
Reference in New Issue
Block a user