コード例 #1
0
        public ActionResult Register(UsersViewModel updateModel)
        {
            string user = updateModel.User.Username;
            if (repo.CheckUserExist(user))
            {
                Session["User"] = user;
                return RedirectToAction("Register", "Admin");
            }

            UsersViewModel uvm = new UsersViewModel();
            uvm.User = new User();
            SaltHashPassword shPass = new SaltHashPassword();

            string pwd = updateModel.User.Password;
            uvm.User.Username = updateModel.User.Username;
            uvm.User.FirstName = updateModel.User.FirstName;
            uvm.User.LastName = updateModel.User.LastName;
            uvm.User.SecretQuestion = updateModel.User.SecretQuestion;
            uvm.User.SecretAnswer = updateModel.User.SecretAnswer;
            uvm.User.PasswordSalt = shPass.GetSaltPassword();
            uvm.User.Password = shPass.GetHashedPassword(pwd);
            uvm.User.Created = DateTime.Now;

            if (ModelState.IsValid)
            {
                repo.AddNewUser(uvm.User);
                //repo.Save();
            }

            return View(uvm);
        }
コード例 #2
0
        public ActionResult Register()
        {
            UsersViewModel uvm = new UsersViewModel();

            return View(uvm);
        }