コード例 #1
0
 public ActionResult Setup(SetupModel setupModel)
 {
     return View(setupModel);
 }
コード例 #2
0
        public ActionResult CreateAdminAccount(SetupModel setupModel)
        {
            if (!sqlMembership.HasAdminAccount())
            {
                if (setupModel.Password != setupModel.RepeatPassword)
                {
                    ModelState.AddModelError("Password", "Passwords must match");
                    ModelState.AddModelError("RepeatPassword", "Passwords must match");
                    return RedirectToAction("Setup", new{setupModel});
                }

                var user = sqlMembership.CreateAccount(setupModel.Name, setupModel.Email, setupModel.Username, setupModel.Password);
                sqlRoleProvider.AddUserToRoles(user, "Admin", "Moderator");
            }

            sqlAuthSettings.SqlAuthenticationEnabled = true;
            settingsProvider.SaveSettings(sqlAuthSettings);

            formsAuthenticator.Logout();
            return RedirectToAction("Index");
        }
コード例 #3
0
        public ActionResult Setup()
        {
            var setupModel = new SetupModel
                                 {
                                     HasAdminAccount = sqlMembership.HasAdminAccount()
                                 };

            return View(setupModel);
        }