public override void OnAuthorization(AuthorizationContext filterContext)
        {
            if (SessionPersiter.User == null)
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "User", action = "Index" }));
            }
            else
            {
                UserModel userMod = new UserModel();

                CustomPrincipal customPrinc = new CustomPrincipal(userMod.Find(SessionPersiter.User.Email));

                if (!customPrinc.IsInRole(UserRoles))
                {
                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "AccessDenied", action = "Index" }));
                }

            }
        }
        public ActionResult Register(User user)
        {

            UserModel userMod = new UserModel();
            if (userMod.Find(user.Email) != null)
            {
                ViewBag.UsernameError = "L'adresse courriel est déjà utilisée doit être unique";
            }

            if (!userMod.Insert(user))
            {
                return View("Register");
            }
            return RedirectToAction("List");
        }
        public ActionResult connexion(string email, string password)
        {
            UserModel userMod = new UserModel();
            User userConnected = userMod.GetUser(email, password);
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)
                || userConnected == null)
            {
                ViewBag.Error = "Le nom d'utilisateur ou le mot de passe est incorrect";
                return View("Index");
            }
            else
            {
                return RedirectToAction("Index", "Home");
            }

        }