Exemple #1
0
        public ActionResult Login(User user)
        {
            SantaClauseVillageMongoDB db = new SantaClauseVillageMongoDB();
            var userAuthentication       = db.GetUserByEmail(user.Email);

            if (userAuthentication != null && userAuthentication.Password == Sha512.GetSHA512(user.PasswordClearText))
            {
                Session["Email"]      = userAuthentication.Email.ToString();
                Session["ID"]         = userAuthentication.ID.ToString();
                Session["ScreenName"] = userAuthentication.Screenname.ToString();
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ModelState.AddModelError("", "Username or Password Error");
            }
            return(View());
        }