Esempio n. 1
0
        public ActionResult Login(AccountViewModels model, string returnUrl)
        {
            string errrMsg = "Invalid login attempt. Your user or password is wrong";

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", errrMsg);
                return(View(model));
            }

            var userInformation = model.validateGG(model.Server, model.UserName, model.Password);

            if (userInformation != null)
            {
                DataRow rowUser = userInformation.Rows[0];
                if (rowUser["is_enabled"].ToString() == "Y")
                {
                    Session["server"]   = model.Server;
                    Session["username"] = model.UserName;
                    Session["userkey"]  = model.Password;
                    FormsAuthentication.SetAuthCookie(model.UserName, false);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("", "The user is disabled in GRIN-Global server");
                    return(View(model));
                }
            }
            ModelState.AddModelError("", errrMsg);
            return(View(model));
        }