function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Utkarsh Verma 22Utkarsh Verma 22 

Critical Update : Restrict Access to @AuraEnabled Apex Methods for Guest and Portal Users Based on User Profile

I created a custom login page which is actually a login form which is a lightning component and this uses an apex controller(class). I have also given user's profile access to apex controller(class). Also tried by using 'with sharing' and 'without sharing' keywords for class, but still getting the error:
Error message: You do not have access to the Apex class named 'MyApexController'
When I deactivated the critical update it is working fine. But when I activate it again it is not working. Please Help..!!
ShirishaShirisha (Salesforce Developers) 
Hi Utkarsh,

Greetings!

As per the release notes,whenever the critical update activates then the guest user will not be able to access the Apex class until you give the access to the class on Guest user Profile.

Reference:https://releasenotes.docs.salesforce.com/en-us/winter20/release-notes/rn_lc_restrict_apex_guest_users.htm

I can see that you have already given the access to  the Apex class.However,I would suggest you to double check if you have given the access to the correct guest profile.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Ubaid KhaliqUbaid Khaliq
Ubaid KhaliqUbaid Khaliq
Utkarsh Verma 22Utkarsh Verma 22
I was unable to resolve this issue. Please help.
ShirishaShirisha (Salesforce Developers) 
Hi,

Have you already checked and confirmed that you have given the access on the Guest user profile with which you are trying to access on the community.

Thank you!
Utkarsh Verma 22Utkarsh Verma 22
Yes Shirisha. Checked it already. After turning off the critical update I am able to achieve the requirement. Does it has anything to do with License?
ShirishaShirisha (Salesforce Developers) 
Oh Ok,Can you please confirm if you have any dependent class/utility classes which are being invoked from the same class.

Also,if possible can you please share the screenshot of the Apex classes section.

>>Go to Sites>>Click on the name of the site>>Click on Public access settings and got to the Profile to see the classes under Apex class category.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Warm Regards,
Shirisha Pathuri