Ejemplo n.º 1
0
        private static RegisterViewModel[] GetUsers()
        {
            var users = new RegisterViewModel[]
                {
                    new RegisterViewModel { Email = "*****@*****.**", Password = "******", ConfirmPassword = "******" },
                    new RegisterViewModel { Email = "*****@*****.**", Password = "******", ConfirmPassword = "******" },
                    new RegisterViewModel { Email = "*****@*****.**", Password = "******", ConfirmPassword = "******" },
                };

            return users;
        }
Ejemplo n.º 2
0
        public async Task<IActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.UserName };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent: false);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    AddErrors(result);
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }