public static void GeneratePass(this Usuarios model) { var passbefore = string.Format("{0}{1}{2}", model.Nombres, model.Sexo, model.Apellidos).ToUpper(); model.Password = ExtensionsHelpers .Hash(passbefore); }
public ResponseHelper Acceder(LoginViewModel model, bool includes) { var rm = new ResponseHelper(); try { using (var ctx = _dbContextScopeFactory.Create()) { //string rol = ""; model.Password = ExtensionsHelpers.Hash(model.Password); var usuario = _usuariosRepository.SingleOrDefault(x => x.Email.Equals(model.username) && x.Password.Equals(model.Password), x => x.Rol); if (includes) { if (usuario != null) { UserSessionHelper.AddUserToSession(usuario.Id.ToString()); UserSessionHelper.AddTipeUser( ExtensionsHelpers.Hash(usuario.Rol.Rol[0].ToString().ToUpper())); rm.SetResponse(true); rm.Result = usuario.Nombres; } else { rm.SetResponse(false, "Correo o contraseƱa incorrecta"); } } else { if (usuario != null) { rm.SetResponse(true); rm.Result = usuario.Nombres; } else { rm.SetResponse(false, "Correo o contraseƱa incorrecta"); } } } } catch (Exception) { throw; } return(rm); }
static void Main(string[] args) { Console.WriteLine(ExtensionsHelpers.Hash("KEITHWALLENM")); Console.WriteLine(ExtensionsHelpers.Hash("KEITHWALLENM")); Console.ReadLine(); }