diff --git a/DisplayCaseController.cls b/DisplayCaseController.cls index eaab6ef..68cf783 100644 --- a/DisplayCaseController.cls +++ b/DisplayCaseController.cls @@ -1,19 +1,26 @@ -public class DisplayCaseController { +public with sharing class DisplayCaseController { @AuraEnabled public static Case getCaseFromId(Id caseID) { + List cases = new List(); + if(caseID == null) { - return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1]; + cases = [SELECT Id, Subject, Description, STATUS from Case LIMIT 1]; + } else { + cases = [ SELECT Id, Subject, Description, Status from CASE where ID = :caseID ]; } - List cases = [ SELECT Id, Subject, Description, Status from CASE where ID = :caseID ]; + SObjectAccessDecision securityDecision = Security.stripInaccessible( + AccessType.READABLE, cases); + cases = securityDecision.getRecords(); + System.debug(cases); if(cases.size() == 0) { - return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1]; + return null; } else { return cases[0]; } } -} \ No newline at end of file +}