Esempio n. 1
0
 public ActionResult Index()
 {
     using (var userManager = IdentityMelodyUserManager.Create())
     {
         return(View(userManager.Users));
     }
 }
Esempio n. 2
0
        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());
            }
        }
Esempio n. 3
0
        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;
 }