Split creators out of identity

This commit is contained in:
Jonathan Bourdon
2024-07-31 23:29:26 -04:00
parent bbcc7a8a33
commit 2b30e1a03c
105 changed files with 1497 additions and 7490 deletions

View File

@@ -1,4 +1,5 @@
using Hutopy.Domain.Constants;
using Hutopy.Infrastructure.Identity;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
@@ -24,7 +25,7 @@ public static class InitializerExtensions
public class ApplicationDbContextInitializer(
ILogger<ApplicationDbContextInitializer> logger,
ApplicationDbContext context,
RoleManager<IdentityRole> roleManager)
RoleManager<ApplicationRole> roleManager)
{
public async Task InitialiseAsync()
{
@@ -54,13 +55,13 @@ public class ApplicationDbContextInitializer(
private async Task TrySeedAsync()
{
var administratorRole = new IdentityRole(Roles.Administrator);
var administratorRole = new ApplicationRole(Roles.Administrator);
if (roleManager.Roles.All(r => r.Name != administratorRole.Name))
{
await roleManager.CreateAsync(administratorRole);
}
var roleCreator = new IdentityRole(Roles.Creator);
var roleCreator = new ApplicationRole(Roles.Creator);
if (roleManager.Roles.All(r => r.Name != roleCreator.Name))
{
await roleManager.CreateAsync(roleCreator);