Ejemplo n.º 1
0
        public ActionResult Autenticate(UserSys userSys, String returnUrl)
        {
            if (ModelState.IsValid)
            {
                AutenticationDTO dto = new AutenticationDTO();
                dto.isLocalURL = Url.IsLocalUrl(returnUrl);
                dto.returnUrl  = returnUrl;
                dto.userSys    = userSys;
                autenticationService.Autenticate(dto);

                if (dto.userLogged != null)
                {
                    if (dto.redirectToReturnURL)
                    {
                        return(Redirect(returnUrl));
                    }

                    Session["isLogged"]     = true;
                    Session["user.name"]    = dto.userLogged.login;
                    Session["user.isAdmin"] = dto.userLogged.userRole.isAdmin;
                    Session["user.id"]      = dto.userLogged.id;

                    return(RedirectToAction("Index", "Customer"));
                }
                else
                {
                    return(RedirectToAction("Index", new { loginFailMessage = dto.loginFailMessage }));
                }
            }

            return(RedirectToAction("Index"));
        }