diff --git a/src/MusicStore/Controllers/AccountController.cs b/src/MusicStore/Controllers/AccountController.cs index 8f11974766..4bfa524bce 100644 --- a/src/MusicStore/Controllers/AccountController.cs +++ b/src/MusicStore/Controllers/AccountController.cs @@ -11,7 +11,7 @@ namespace MusicStore.Controllers [Authorize] public class AccountController : Controller { - public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager) + public AccountController(UserManager userManager, SignInManager signInManager) { UserManager = userManager; SignInManager = signInManager; @@ -19,14 +19,14 @@ namespace MusicStore.Controllers public UserManager UserManager { get; private set; } - public ApplicationSignInManager SignInManager { get; private set; } + public SignInManager SignInManager { get; private set; } // // GET: /Account/Login [AllowAnonymous] //Bug: https://github.com/aspnet/WebFx/issues/339 [HttpGet] - public IActionResult Login(string returnUrl) + public IActionResult Login(string returnUrl=null) { ViewBag.ReturnUrl = returnUrl; return View(); @@ -37,7 +37,7 @@ namespace MusicStore.Controllers [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] - public async Task Login(LoginViewModel model, string returnUrl) + public async Task Login(LoginViewModel model, string returnUrl=null) { if (ModelState.IsValid) { @@ -100,7 +100,7 @@ namespace MusicStore.Controllers // GET: /Account/Manage //Bug: https://github.com/aspnet/WebFx/issues/339 [HttpGet] - public IActionResult Manage(ManageMessageId? message) + public IActionResult Manage(ManageMessageId? message=null) { ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." diff --git a/src/MusicStore/Models/IdentityModels.cs b/src/MusicStore/Models/IdentityModels.cs index c7ee5b4103..b673f96706 100644 --- a/src/MusicStore/Models/IdentityModels.cs +++ b/src/MusicStore/Models/IdentityModels.cs @@ -1,29 +1,10 @@ using System; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.Entity; -using Microsoft.AspNet.Identity.Security; using Microsoft.Data.Entity; using Microsoft.Framework.ConfigurationModel; -using Microsoft.Framework.DependencyInjection; namespace MusicStore.Models { - public class ApplicationUserManager : UserManager - { - public ApplicationUserManager(IServiceProvider services, IUserStore store, IOptionsAccessor optionsAccessor) : base(services, store, optionsAccessor) { } - } - - public class ApplicationRoleManager : RoleManager - { - public ApplicationRoleManager(IServiceProvider services, IRoleStore store) : base(services, store) { } - } - - public class ApplicationSignInManager : SignInManager - { - public ApplicationSignInManager(ApplicationUserManager manager, IContextAccessor contextAccessor) : base(manager, contextAccessor) { } - } - public class ApplicationUser : User { } public class ApplicationDbContext : IdentitySqlContext diff --git a/src/MusicStore/Startup.cs b/src/MusicStore/Startup.cs index e4c7bd1d61..6e43c9c14d 100644 --- a/src/MusicStore/Startup.cs +++ b/src/MusicStore/Startup.cs @@ -1,27 +1,15 @@ -using Microsoft.AspNet; -using Microsoft.AspNet.Http; using Microsoft.AspNet.Builder; -using Microsoft.Framework.ConfigurationModel; -using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.DependencyInjection.Fallback; using Microsoft.AspNet.Diagnostics; +using Microsoft.AspNet.Http; using Microsoft.AspNet.Identity; -using Microsoft.AspNet.Identity.Entity; -using Microsoft.AspNet.Identity.InMemory; using Microsoft.AspNet.Identity.Security; -using Microsoft.Framework.Logging; -using Microsoft.AspNet.Mvc; -using Microsoft.AspNet.RequestContainer; using Microsoft.AspNet.Routing; using Microsoft.AspNet.Security.Cookies; using Microsoft.Data.Entity; -using Microsoft.Data.Entity.InMemory; -using Microsoft.Data.Entity.SqlServer; -using Microsoft.Framework.Runtime; +using Microsoft.Framework.ConfigurationModel; +using Microsoft.Framework.DependencyInjection; using MusicStore.Models; using System; -using System.Collections.Generic; -using System.IO; using System.Security.Claims; using System.Threading.Tasks; @@ -47,20 +35,13 @@ public class Startup services.AddEntityFramework().AddSqlServer(); services.AddTransient(); - - /* - * Add all Identity related services to IoC. - */ + //Add all Identity related services to IoC. services.AddTransient(); - - //Bug: https://github.com/aspnet/Identity/issues/50 services.AddIdentity(s => { s.AddEntity(); - s.AddUserManager(); - s.AddRoleManager(); }); - services.AddTransient(); + services.AddTransient>(); }); @@ -106,9 +87,9 @@ public class Startup var password = configuration.Get("DefaultAdminPassword"); //const string adminRole = "Administrator"; - var userManager = serviceProvider.GetService(); + var userManager = serviceProvider.GetService>(); // Todo: identity sql does not support roles yet - //var roleManager = serviceProvider.GetService(); + //var roleManager = serviceProvider.GetService>(); //if (!await roleManager.RoleExistsAsync(adminRole)) //{ // await roleManager.CreateAsync(new IdentityRole(adminRole));