Esempio n. 1
0
 public ActionResult Index(UserForm userForm)
 {
     if (ModelState.IsValid)
     {
         if (UserRepository.UsernameNotTaken(userForm.Username))
         {
             User newUser = new User();
             newUser.Username = userForm.Username;
             newUser.Password = userForm.Password;
             newUser.IsAdmin = false;
             newUser = UserRepository.Save(newUser);
             newUser.Password = "******";
             Session["CurrentUser"] = newUser;
             return RedirectToAction("Index", "Home", new { Area = "" });
         }
     }
     return View(userForm);
 }
Esempio n. 2
0
        public ActionResult Index(UserForm userForm)
        {
            if (ModelState.IsValid)
            {
                User loggedUser = UserRepository.LogInUser(userForm.Username, userForm.Password);
                if (loggedUser != null)
                {
                    loggedUser.Password = "******";
                    Session["CurrentUser"] = loggedUser;
                    return RedirectToAction("Index", "Home", new { Area = "" });
                }
                else
                {
                    return View();
                }
            }
            else
            {
                return View(userForm);
            }

        }