Esempio n. 1
0
        public ActionResult Connexion(string username, string password, string ReturnUrl = "")
        {
            str = Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"];
            string cookie = "";

            if (this.ControllerContext.HttpContext.Request.Cookies.AllKeys.Contains("Cookie"))
            {
                cookie         = this.ControllerContext.HttpContext.Request.Cookies["Cookie"].Value;
                ViewBag.cookie = cookie;
                CreateCulture(cookie);
            }
            else
            {
                CreateCulture(str);
            }

            ViewBag.error     = "";
            ViewBag.ReturnUrl = ReturnUrl;
            if (!Utilisateurs.Authentifie(username, password))
            {
                ViewBag.error = "Nom d'utilisateur ou mot de passe invalide!";
                return(View());
            }
            else
            {
                FormsAuthentication.SetAuthCookie(username, false);
                if (ReturnUrl == "")
                {
                    return(RedirectToAction("index", "home"));
                }
                else
                {
                    return(Redirect(ReturnUrl));
                }
            }
        }