public override bool ValidateUser(string username, string password) { try { bool usuarioValido = false; if (string.IsNullOrEmpty(password.Trim()) || string.IsNullOrEmpty(username.Trim())) { return(false); } var response = _Empleados.ObtenerEmpleados(username); if (response.Code < 0) { throw new Exception(response.Message); } if (response.Result == null) { return(false); } var respGenHM = encript.GenerateHMAC(password, response.Result.Salt); string passHashed = respGenHM.Result.ToString(); if (response.Result.Password_Empleado.Trim() == passHashed.Trim()) { usuarioValido = true; } return(usuarioValido); } catch (Exception ex) { throw ex; } }
//[ValidateAntiForgeryToken] public ActionResult LoginAuth(AccountLoginViewModel login) { EncriptPasswordSha3 encript = new EncriptPasswordSha3(); if (string.IsNullOrEmpty(login.Username)) { ModelState.AddModelError("Username", "El Usuario es obligatorio"); } if (string.IsNullOrEmpty(login.Password)) { ModelState.AddModelError("Password", "La contraseƱa es obligatoria"); } if (ModelState.IsValid) { //var resUsCheca = _Empleados.ObtenerEmpleados(login.Username); if (MembershipService.ValidateUser(login.Username, login.Password)) { var usuario = _Empleados.ObtenerEmpleados(login.Username); Session[Constantes.Session.Usuario] = usuario.Result; Session[Constantes.Session.Empresa] = usuario.Result.Id_Empresa; FormsAuthentication.SetAuthCookie(usuario.Result.Id_Empleado.ToString(), false); return(RedirectToLocal(login.returnUrl)); } else { ViewBag.MensajeError = "Usuario o password incorrecto"; } } ViewBag.Login = true; return(View(login)); }