public ActionResult Login(LoginViewModel model) { //Verificar en la base de datos var userFound = uw.UserRepository.GetAll(item => item.Email == model.Login).FirstOrDefault(); uw.Dispose(); if (userFound != null) { if (!SecurityInfra.VerifyHashedPassword(userFound.SenhaHash, model.Password)) { model.MensajeValidacion = "Autentication error"; return(View(model)); } //Ingreso a la aplicación var claims = SecurityHelpers.CreateClaimsUsuario(userFound); var identity = new ClaimsIdentity(claims, "ApplicationCookie"); var context = Request.GetOwinContext(); var authManager = context.Authentication; authManager.SignIn(identity); return(Redirect(model.ReturnUrl ?? "~/")); } else { model.MensajeValidacion = "Usuario no registrado en el sistema"; return(View(model)); } }
public bool Put(User model) { model.SenhaHash = SecurityInfra.HashPassword(model.SenhaHash); model.Roles = "user"; uw.UserRepository.Add(model); var result = uw.Complete() > 0; return(result); }