feat: pivot to social media workflow app
Some checks failed
Backend CI/CD / build_and_deploy (push) Has been cancelled
Frontend CI/CD / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-04-24 12:58:35 -04:00
parent 0f4acc1b6d
commit df3e602015
349 changed files with 18685 additions and 16010 deletions

View File

@@ -1,19 +1,17 @@
using Hutopy.Modules.Identity.Configuration;
using Hutopy.Modules.Identity.Contracts;
using Hutopy.Modules.Identity.Data;
using Hutopy.Modules.Identity.Services;
using Socialize.Data;
using Socialize.Modules.Identity.Configuration;
using Socialize.Modules.Identity.Contracts;
using Socialize.Modules.Identity.Data;
using Socialize.Modules.Identity.Services;
using Microsoft.AspNetCore.Identity;
namespace Hutopy.Modules.Identity;
namespace Socialize.Modules.Identity;
public static class DependencyInjection
{
public static WebApplicationBuilder AddIdentityModule(
this WebApplicationBuilder builder,
Action<DbContextOptionsBuilder>? configureAction = null)
this WebApplicationBuilder builder)
{
builder.Services.AddDbContext<IdentityDbContext>(configureAction);
builder.Services.Configure<JwtOptions>(
builder.Configuration.GetRequiredSection(JwtOptions.SectionName));
@@ -23,10 +21,24 @@ public static class DependencyInjection
builder.Services.AddAuthorizationBuilder();
builder.Services
.Configure<IdentityOptions>(options =>
{
if (!builder.Environment.IsDevelopment())
{
return;
}
options.Password.RequireDigit = false;
options.Password.RequireLowercase = false;
options.Password.RequireUppercase = false;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequiredLength = 3;
options.Password.RequiredUniqueChars = 1;
})
.AddIdentityCore<User>()
.AddUserManager<UserManager>()
.AddRoles<Role>()
.AddEntityFrameworkStores<IdentityDbContext>()
.AddEntityFrameworkStores<AppDbContext>()
.AddApiEndpoints()
.AddDefaultTokenProviders();
@@ -36,6 +48,7 @@ public static class DependencyInjection
// Scoped services
builder.Services.AddScoped<IdentityService>();
builder.Services.AddScoped<EmailVerificationService>();
builder.Services.AddScoped<AccessTokenFactory>();
builder.Services.AddScoped<IUserLookup, UserLookup>();
return builder;
@@ -47,9 +60,6 @@ public static class DependencyInjection
{
IServiceScopeFactory scopeFactory = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>();
using IServiceScope scope = scopeFactory.CreateScope();
await using IdentityDbContext context = scope.ServiceProvider.GetRequiredService<IdentityDbContext>();
await context.Database.MigrateAsync(cancellationToken);
RoleManager<Role> roleManager = scope.ServiceProvider.GetRequiredService<RoleManager<Role>>();
await TrySeedAsync(roleManager);
@@ -64,10 +74,28 @@ public static class DependencyInjection
await roleManager.CreateAsync(administratorRole);
}
Role roleCreator = new(KnownRoles.Creator);
if (roleManager.Roles.All(r => r.Name != roleCreator.Name))
Role managerRole = new(KnownRoles.Manager);
if (roleManager.Roles.All(r => r.Name != managerRole.Name))
{
await roleManager.CreateAsync(roleCreator);
await roleManager.CreateAsync(managerRole);
}
Role clientRole = new(KnownRoles.Client);
if (roleManager.Roles.All(r => r.Name != clientRole.Name))
{
await roleManager.CreateAsync(clientRole);
}
Role providerRole = new(KnownRoles.Provider);
if (roleManager.Roles.All(r => r.Name != providerRole.Name))
{
await roleManager.CreateAsync(providerRole);
}
Role workspaceMemberRole = new(KnownRoles.WorkspaceMember);
if (roleManager.Roles.All(r => r.Name != workspaceMemberRole.Name))
{
await roleManager.CreateAsync(workspaceMemberRole);
}
}
}