Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Name,Description,FamilyName,HomeAddress,City,State,ZIP,Username,Email,Password,ConfirmPassword,PasswordQuestion,PasswordAnswer,PhoneNumber,DateOfBirth,FirstName,LastName")] SetupSystemViewModel setupInfo)
        {
            if (setupInfo.Password == setupInfo.ConfirmPassword)
            {
                RNGCryptoServiceProvider csprng = new RNGCryptoServiceProvider();
                byte[] salt = new byte[SALT_BYTE_SIZE];
                csprng.GetBytes(salt);

                var hashedPassword = Hash.CreateHash(setupInfo.Password.ToString(), salt);
                if (ModelState.IsValid)
                {
                    db.SetupSystem(setupInfo.Name, setupInfo.HomeAddress, setupInfo.City, setupInfo.State, setupInfo.ZIP, setupInfo.Description, setupInfo.FamilyName, setupInfo.Username, setupInfo.Email, hashedPassword, salt, setupInfo.PhoneNumber, setupInfo.PasswordQuestion, setupInfo.PasswordAnswer, setupInfo.DateOfBirth, setupInfo.FirstName, setupInfo.LastName);
                    return(RedirectToAction("Login", "Account"));
                }
                else
                {
                    ViewBag.LoginError = "Error: Invalid Information";
                    return(View());
                }
            }
            else
            {
                ViewBag.LoginError = "Error: Invalid Information";
                return(View(setupInfo));
            }
        }