Fix build issues in Startup.cs
Update for Identity API changes
This commit is contained in:
parent
e4af75dddf
commit
5bb8f602f1
|
|
@ -81,22 +81,22 @@ public class Startup
|
||||||
string _password = "YouShouldChangeThisPassword"; // configuration.Get("DefaultAdminPassword");
|
string _password = "YouShouldChangeThisPassword"; // configuration.Get("DefaultAdminPassword");
|
||||||
string _role = "Administrator";
|
string _role = "Administrator";
|
||||||
|
|
||||||
var userManager = new UserManager<ApplicationUser, string>(new InMemoryUserStore<ApplicationUser>());
|
var userManager = new UserManager<ApplicationUser>(new InMemoryUserStore<ApplicationUser>());
|
||||||
var roleManager = new RoleManager<InMemoryRole>(new InMemoryRoleStore<InMemoryRole>());
|
var roleManager = new RoleManager<InMemoryRole>(new InMemoryRoleStore<InMemoryRole>());
|
||||||
|
|
||||||
var role = new InMemoryRole(_role);
|
var role = new InMemoryRole(_role);
|
||||||
var result = await roleManager.RoleExists(_role);
|
var result = await roleManager.RoleExistsAsync(_role);
|
||||||
if (result == false)
|
if (result == false)
|
||||||
{
|
{
|
||||||
await roleManager.Create(role);
|
await roleManager.CreateAsync(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
var user = await userManager.FindByName(_username);
|
var user = await userManager.FindByNameAsync(_username);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
user = new ApplicationUser { UserName = _username };
|
user = new ApplicationUser { UserName = _username };
|
||||||
await userManager.Create(user, _password);
|
await userManager.CreateAsync(user, _password);
|
||||||
await userManager.AddToRole(user.Id, _role);
|
await userManager.AddToRoleAsync(user.Id, _role);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue