I was under the impression that if you declared your classes as:
global with sharing class HsignUtils {
...
}
Then any SOQL you ran in there would be automatically mindful of CRUD/FLS permissions. However I recently had a lot of lines flagged in a security review which indicate that those queries (some insert, some delete, some update, some select) are not properly respecting CRUD/FLS Enforcement.
What am I misunderstanding about 'global with sharing'? And is a there a single global way (maybe a line at the top of my class) I can do to check for these permissions?
As it stands I'm having to wrap each and every SOQL call in a check like this:
if (Schema.sObjectType.Contact.fields.Id.isAccessible() == true {
objectNumContacts = (Integer)[select COUNT(Id) from Contact where AccountId=:originObjectIdString and Contact.Name!=Null and Contact.Email!=Null][0].get('expr0');
}
Which is extremely time consuming. Is there a better way to do this?