예제 #1
0
        public ActionResult Login(AuthenticationLoginViewModels model)
        {
            if (ModelState.IsValid)
            {
                var passwordHash = model.Password.HashMD5();

                var user = db.Users.SingleOrDefault(x => x.Mail == model.Login && x.Password == passwordHash);
                if (user == null)
                {
                    //1
                    //ModelState.AddModelError("", "Utilisateur ou mot de passe incorrect");

                    //2
                    ViewBag.ErrorMessage = "Utilisateur ou mot de passe incorrect";

                    return(View(model));
                    //return RedirectToAction("Login");
                }
                else
                {
                    Session.Add("USER_BO", user);
                    return(RedirectToAction("Index", "Dashboard", new { area = "BackOffice" }));
                }
            }
            return(View(model));
        }
예제 #2
0
        public ActionResult Login(AuthenticationLoginViewModels model)
        {
            var hash   = model.Password.HashMD5();
            var archer = db.Archers.SingleOrDefault(x => x.Mail == model.Mail && x.Password == hash);

            if (archer == null)
            {
                Display("Login/Mot de passe incorrect", MessageType.ERROR);
                return(View());
            }
            else
            {
                Session["ARCHER"] = archer;
                if (TempData["REDIRECT"] != null)
                {
                    return(Redirect(TempData["REDIRECT"].ToString()));
                }
                else
                {
                    return(RedirectToAction("Index", "Home", new { area = "" }));
                }
            }
        }
예제 #3
0
        public ActionResult Login(AuthenticationLoginViewModels model)
        {
            if (ModelState.IsValid)
            {
                //var hash = model.Password.HashMD5();
                //var admin = db.Administrators.SingleOrDefault(x => x.Mail == model.Mail && x.Password == hash);
                var admin = db.Administrators.SingleOrDefault(x => x.Mail == model.Mail && x.Password == model.Password);

                if (admin == null)
                {
                    ModelState.AddModelError("Mail", "Login / mot de passe invalide");
                    return(View());
                }
                else
                {
                    Session["ADMINISTRATOR"] = admin;
                    //Session["AdminName"] = admin.FirstName;

                    return(RedirectToAction("Index", "Dashboard", new { area = "BackOffice" })); //area inutile ici puisque nous sommes déjà dedans mais cela n'affecte rien de la mettre quand même
                }
            }
            return(View());
        }
예제 #4
0
 public ActionResult Login(AuthenticationLoginViewModels model)
 {
     if (ModelState.IsValid)
     {
         var hash    = model.Password.HashMD5();
         var manager = db.SalesManagers.SingleOrDefault(x => x.Mail == model.Mail && x.Password == hash);
         if (manager == null)
         {
             Display("Login/Mot de passe incorrect", MessageType.ERROR);
             return(View());
         }
         else
         {
             Session["SALESMANAGER"] = manager;
             if (TempData["REDIRECT"] != null)
             {
                 return(Redirect(TempData["REDIRECT"].ToString()));
             }
             return(RedirectToAction("Index", "Dashboard", new { area = "BackOffice" }));
         }
     }
     return(View());
 }