fix: exibição do plano
Some checks failed
BCards Deployment Pipeline / Deploy to Production (ARM - OCI) (push) Blocked by required conditions
BCards Deployment Pipeline / Deploy to Staging (x86 - Local) (push) Blocked by required conditions
BCards Deployment Pipeline / Cleanup Old Resources (push) Blocked by required conditions
BCards Deployment Pipeline / Deployment Summary (push) Blocked by required conditions
BCards Deployment Pipeline / Run Tests (push) Successful in 1s
BCards Deployment Pipeline / PR Validation (push) Has been skipped
BCards Deployment Pipeline / Build and Push Image (push) Has been cancelled

This commit is contained in:
Ricardo Carneiro 2025-09-08 22:12:07 -03:00
parent dde67df72f
commit 90a1ee2bfb
2 changed files with 15 additions and 0 deletions

View File

@ -60,7 +60,13 @@ public class AdminController : Controller
if (user == null) if (user == null)
return RedirectToAction("Login", "Auth"); return RedirectToAction("Login", "Auth");
_logger.LogInformation("[DASHBOARD DEBUG] User {UserId} ({Email}) - CurrentPlan: '{CurrentPlan}'",
user.Id, user.Email, user.CurrentPlan ?? "NULL");
var userPlanType = Enum.TryParse<PlanType>(user.CurrentPlan, true, out var planType) ? planType : PlanType.Trial; var userPlanType = Enum.TryParse<PlanType>(user.CurrentPlan, true, out var planType) ? planType : PlanType.Trial;
_logger.LogInformation("[DASHBOARD DEBUG] Parsed PlanType: {PlanType} (from '{CurrentPlan}')",
userPlanType, user.CurrentPlan ?? "NULL");
var userPages = await _userPageService.GetUserPagesAsync(user.Id); var userPages = await _userPageService.GetUserPagesAsync(user.Id);
var listCounts = new Dictionary<string, dynamic>(); var listCounts = new Dictionary<string, dynamic>();

View File

@ -443,6 +443,15 @@ public class StripeWebhookController : ControllerBase
await _subscriptionRepository.CreateAsync(newSubscription); await _subscriptionRepository.CreateAsync(newSubscription);
_logger.LogInformation($"[TID: {traceId}] - Created new subscription {newSubscription.Id} for user {user.Id}"); _logger.LogInformation($"[TID: {traceId}] - Created new subscription {newSubscription.Id} for user {user.Id}");
// 🔥 CORREÇÃO: Update user's CurrentPlan
_logger.LogInformation($"[TID: {traceId}] - Updating user {user.Id} CurrentPlan from '{user.CurrentPlan}' to '{planType}'");
user.CurrentPlan = planType;
user.UpdatedAt = DateTime.UtcNow;
var usersCollection = mongoDatabase.GetCollection<Models.User>("users");
await usersCollection.ReplaceOneAsync(u => u.Id == user.Id, user);
_logger.LogInformation($"[TID: {traceId}] - User {user.Id} CurrentPlan updated to '{planType}'");
// Activate user pages that were pending payment or expired // Activate user pages that were pending payment or expired
var userPages = await _userPageService.GetUserPagesAsync(user.Id); var userPages = await _userPageService.GetUserPagesAsync(user.Id);
foreach (var page in userPages.Where(p => foreach (var page in userPages.Where(p =>