Exemple #1
0
 public ActionResult Login(LoginViewModel model, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         try
         {
             BarcoSoftAuthorize.LogIn(this.HttpContext, model.Password.Encrypt(), model.Email);
             FormsAuthentication.RedirectFromLoginPage(model.Email, false);
             return(Redirect(returnUrl));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
     }
     return(View());
 }
Exemple #2
0
        public async Task <ActionResult> Register(Ekilibrate.Model.Entity.Participante.clsRegistroParticipante model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (model.Password == model.ConfirmPassword)
                    {
                        using (var scope = EkilibrateUI.Autofac.ContainerConfig.ProxyContainer.BeginLifetimeScope())
                        {
                            var middleTier = scope.Resolve <Ekilibrate.Model.Services.Participante.IDataInjector>();
                            var usr        = await middleTier.CrearParticipante(model);

                            BarcoSoftAuthorize.LogIn(this.HttpContext, model.Password.Encrypt(), usr);
                            FormsAuthentication.SetAuthCookie(usr, false);

                            BarcoSoftUtilidades.Seguridad.Usuario user = this.HttpContext.GetActualUser();
                            if (user.Tipo.IdTipoUsuario == 6)
                            {
                                return(Redirect(user.Tipo.RedirectUrlTipoUsuario));
                            }
                            //return Redirect("~/SitioAdministrativo/Home/Lock");
                            else
                            {
                                return(Redirect(user.Tipo.RedirectUrlTipoUsuario));
                            }
                        }
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Las contraseñas ingresadas no coinciden");
                    }
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Verifica tu datos.");
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
            }
            return(View(model));
        }
Exemple #3
0
        public ActionResult Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    BarcoSoftAuthorize.LogIn(this.HttpContext, model.Password.Encrypt(), model.Email.Trim());
                    FormsAuthentication.SetAuthCookie(model.Email, false);

                    if (model.returnUrl != null && model.returnUrl.Length > 0 && !model.returnUrl.EndsWith("/") && !model.returnUrl.EndsWith("EkilibrateUI"))
                    {
                        if (Request.Url.Host == "localhost" && !model.returnUrl.Contains("EkilibrateUI"))
                        {
                            return(Redirect("/EkilibrateUI" + model.returnUrl));
                        }
                        else
                        {
                            return(Redirect(model.returnUrl));
                        }
                    }
                    else
                    {
                        BarcoSoftUtilidades.Seguridad.Usuario user = this.HttpContext.GetActualUser();
                        if (user.Tipo.IdTipoUsuario == 6)
                        {
                            return(Redirect(user.Tipo.RedirectUrlTipoUsuario));
                        }
                        //return Redirect("~/SitioAdministrativo/Home/Lock");
                        else
                        {
                            return(Redirect(user.Tipo.RedirectUrlTipoUsuario));
                        }
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
            }
            return(View());
        }