mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-10-31 18:47:05 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			763 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			763 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Collections.Generic;
 | |
| using System.Threading.Tasks;
 | |
| using API.Constants;
 | |
| using API.Entities;
 | |
| using Microsoft.AspNetCore.Identity;
 | |
| 
 | |
| namespace API.Data
 | |
| {
 | |
|     public static class Seed
 | |
|     {
 | |
|         public static async Task SeedRoles(RoleManager<AppRole> roleManager)
 | |
|         {
 | |
|             var roles = new List<AppRole>
 | |
|             {
 | |
|                 new() {Name = PolicyConstants.AdminRole},
 | |
|                 new() {Name = PolicyConstants.PlebRole}
 | |
|             };
 | |
| 
 | |
|             foreach (var role in roles)
 | |
|             {
 | |
|                 var exists = await roleManager.RoleExistsAsync(role.Name);
 | |
|                 if (!exists)
 | |
|                 {
 | |
|                     await roleManager.CreateAsync(role);      
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| } |