public async Task<ActionResult> Login(string returnUrl)
{
// ############################################################
// Account/Login code was modified
// Its purpose is to create a new 'admin' user (with a password of 'Password123!')
// the first time that the login view/page appears
// The method's signature was also changed to run asynchronously
if (UserManager.Users.Count() == 0)
{
var user = new ApplicationUser { UserName = "[email protected]", Email = "[email protected]" };
var result = await UserManager.CreateAsync(user, "Password123!");
// Add claims
await UserManager.AddClaimAsync(user.Id, new Claim(ClaimTypes.Email, "[email protected]"));
await UserManager.AddClaimAsync(user.Id, new Claim(ClaimTypes.Role, "Admin"));
await UserManager.AddClaimAsync(user.Id, new Claim(ClaimTypes.GivenName, "Application"));
await UserManager.AddClaimAsync(user.Id, new Claim(ClaimTypes.Surname, "Administrator"));
}
// End of new code block
// ############################################################
ViewBag.ReturnUrl = returnUrl;
return View();
}