コード例 #1
0
ファイル: SampleData.cs プロジェクト: johndelfGM/NerdDinner
        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;
        }
コード例 #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);
        }