Beispiel #1
0
        public ActionResult compte(Authentifications ath)
        {
            var    response  = Request["g-recaptcha-response"];
            string secretKey = "your secret key here";
            var    client    = new WebClient();
            var    result    = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secretKey, response));
            var    obj       = JObject.Parse(result);
            var    status    = (bool)obj.SelectToken("success");

            ViewBag.Message = status ? "Google reCaptcha validation success" : "Google reCaptcha validation failed";


            if (ModelState.IsValid)
            {
                using (Manage_BooksEntities1 ml = new Manage_BooksEntities1())
                {
                    ml.Authentifications.Add(ath);
                    ml.SaveChanges();

                    ViewBag.Message = "Cette Compte est Bien Cree";
                    RedirectToAction("login");
                }
            }

            return(View("login"));
        }
        public ActionResult login(Authentifications log)
        {
            if (ModelState.IsValid)
            {
                using (Manage_BooksEntities1 con = new Manage_BooksEntities1())
                {
                    var mk = con.Authentifications.Where(a => a.User_Name.Equals(log.User_Name) && a.Password_cle.Equals(log.Password_cle)).FirstOrDefault();
                    if (mk != null)
                    {
                        Session["UserId"]   = mk.User_Name.ToString();
                        Session["Password"] = mk.Password_cle.ToString();

                        return(RedirectToAction("list"));
                    }
                    //ViewBag.Message = "Successfully Registration Done";
                }
            }
            return(View(log));
        }