This is more of a best practices question. Our org currently has “public read” permissions on our org wide defaults for custom objects. We cannot make this private because of the way its working now for internal employees or rather we are trying to avoid this.
I am also creating a customer portal with custom visual force pages…where I display data using SOQL queries.
Is it a good idea to add a clause on the SOQL query to return only those records where the account id matches the logged in user’s acount id?
I did it and it works fine…But are there any pitfalls to this method that I am overlooking?
Thanks,
Calvin
Per the Visualforce Documentation
I believe the idea being, as long as your classes are
public with sharingthen permissions should be enforced and records should not be returned that the user cannot see (same with fields on a record).per the Apex Documentation
Use the
with sharingkeywords when declaring a class to enforce the sharing rules that apply to the current user. For example:Use the
without sharingkeywords when declaring a class to ensure that the sharing rules for the current user are not enforced. For example:Otherwise you would have to spend hours ensuring that the right permissions applied at exactly the right time for the right user. It would almost completely defeat the purpose of a visualforce page!