public Envelope <List <dynamic> > GetAll(dynamic data, UsuariosDS usuariosDS) { try { var result = usuariosDS.GetDataSet(fields: "[iUsuario],[Usuario],[Nombre],[Apellidos],[Email],[IsActive]"); return(result); } catch (Exception ex) { return(new Envelope <List <dynamic> >() { Result = "error", Message = ex.Message }); } }
public Envelope <List <dynamic> > GetProfile(dynamic data, UsuariosDS usuariosDS) { try { string options = $" WHERE Usuario = '{data.AuthUser}' "; var result = usuariosDS.GetDataSet(fields: "[iUsuario],[Usuario],[Nombre],[Apellidos],[Email]", options: options); return(result); } catch (Exception ex) { return(new Envelope <List <dynamic> >() { Result = "error", Message = ex.Message }); } }
public Envelope <dynamic> CambiarPass(dynamic data, UsuariosDS usuariosDS) { try { string usuario = data.AuthUser; string password = data.previoPassword; string options = $" WHERE Usuario = '{usuario}' "; var requestUser = usuariosDS.GetDataSet(fields: "[iUsuario],[Usuario],[Password],[PasswordSalt]", options: options); if (requestUser.Result != "ok") { return(new Envelope <dynamic>() { Result = "notSuccess", Message = "User not found" }); } var dataSet = requestUser.Data.FirstOrDefault(); if (HashHL.SHA256Of($"{usuario}{password}{dataSet.PasswordSalt}") != dataSet.Password && dataSet.Password != password) { return(new Envelope <dynamic>() { Result = "notSuccess", Message = "Wrong passord" }); } else { dynamic data2 = JsonConvert.DeserializeObject("{}"); data2.id = dataSet.iUsuario; data2.PasswordSalt = Guid.NewGuid().ToString();; data2.Password = HashHL.SHA256Of($"{usuario}{data.nuevoPassword}{data2.PasswordSalt}");; var updateResponse = usuariosDS.Update(data2); return(updateResponse); } } catch (Exception ex) { return(new Envelope <dynamic>() { Result = "error", Message = ex.Message }); } }