Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override void Seed(Musikeroo.Models.ApplicationDbContext context)
- {
- var store = new RoleStore<IdentityRole>(context);
- var manager = new RoleManager<IdentityRole>(store);
- if (!context.Roles.Any(r => r.Name == "Client"))
- {
- manager.Create(new IdentityRole { Name = "Client" });
- }
- if (!context.Roles.Any(r => r.Name == "Admin"))
- {
- manager.Create(new IdentityRole { Name = "Admin" });
- }
- if (!context.Users.Any(u => u.UserName == "ad@m.in"))
- {
- string password = new PasswordHasher().HashPassword("https://localhost:44309/Account/Login");
- context.Users.AddOrUpdate(u => u.UserName,
- new ApplicationUser
- {
- UserName = "ad@m.in",
- PasswordHash = password,
- Email = "ad@m.in",
- FirstName = "Admin",
- LastName = "YOLO",
- }
- );
- Roles.AddUserToRole("ad@m.in", "Admin");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement