Advertisement
Lauda

Untitled

May 14th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.55 KB | None | 0 0
  1. public static void ConfigureIdentityRoles(this IApplicationBuilder app, IServiceProvider serviceProvider)
  2. +       {
  3. +           var roleManager = serviceProvider.GetRequiredService<RoleManager<AppRole>>();
  4. +           string[] roleNames = { "Admin", "Owner", "Customer", "Agent" }; // TODO: switch TO enum OR const
  5. +
  6. +           foreach (var roleName IN roleNames)
  7. +           {
  8. +               var roleExist = roleManager.RoleExistsAsync(roleName).GetAwaiter().GetResult();
  9. +               IF (!roleExist)
  10. +               {
  11. +                   roleManager.CreateAsync(NEW AppRole(roleName)).GetAwaiter().GetResult();
  12. +               }
  13. +           }
  14. +
  15. +       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement