public ActionResult Index() { using (var userManager = IdentityMelodyUserManager.Create()) { return(View(userManager.Users)); } }
public ActionResult Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View()); } using (var userManager = IdentityMelodyUserManager.Create()) { var user = userManager.Find(model.UserName, model.Password); if (user != null) { var authentictionManager = HttpContext.GetOwinContext().Authentication; authentictionManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); var userIdentity = userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); authentictionManager.SignIn(new AuthenticationProperties { IsPersistent = false }, userIdentity); return(Redirect(returnUrl ?? Url.Action("Index", "Home"))); } ModelState.AddModelError("", "Incorrect username or password"); return(View()); } }
public ActionResult Create(CreateMusicUserModel model) { if (!ModelState.IsValid) { return(View(model)); } var user = new MusicUser { UserName = model.Name, Email = model.Email }; using (var userManager = IdentityMelodyUserManager.Create()) { var result = userManager.Create(user, model.Password); if (result.Succeeded) { return(RedirectToAction("Index")); } AddErrorsFromResult(result); } return(View(model)); }
public AccountCommandController(IdentityMelodyUserManager userManager, IAuthenticationManager authentictionManager) { _userManager = userManager; _authentictionManager = authentictionManager; }