feat: implement identity authentication, authorization policies, and MAUI platform support with Docker orchestration

This commit is contained in:
2026-04-29 20:37:41 +02:00
parent 10efed0369
commit 0210611edf
55 changed files with 2359 additions and 949 deletions
@@ -0,0 +1,53 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using NexusReader.Application.Abstractions.Services;
using NexusReader.Domain.Entities;
using NexusReader.Infrastructure.Persistence;
namespace NexusReader.Infrastructure.Services;
public class BillingService : IBillingService
{
private readonly AppDbContext _dbContext;
private readonly UserManager<NexusUser> _userManager;
public BillingService(AppDbContext dbContext, UserManager<NexusUser> userManager)
{
_dbContext = dbContext;
_userManager = userManager;
}
public async Task<bool> HandleSubscriptionUpdatedAsync(string customerEmail, string stripeProductId)
{
var user = await _userManager.FindByEmailAsync(customerEmail);
if (user == null) return false;
// Map Stripe Product IDs to Nexus Plans
// These IDs would typically come from configuration
if (stripeProductId.Contains("pro"))
{
user.CurrentPlan = "Pro";
user.AITokenLimit = 50000;
}
else if (stripeProductId.Contains("basic"))
{
user.CurrentPlan = "Basic";
user.AITokenLimit = 10000;
}
await _userManager.UpdateAsync(user);
return true;
}
public async Task<bool> HandleSubscriptionDeletedAsync(string customerEmail)
{
var user = await _userManager.FindByEmailAsync(customerEmail);
if (user == null) return false;
user.CurrentPlan = "Free";
user.AITokenLimit = 1000; // Reset to free limit
await _userManager.UpdateAsync(user);
return true;
}
}