2

I am getting the following error for my LWC Controller. It seems that users do not have access to an Apex class.

enter image description here

This LWC has been working for almost a year, but it seems something in my org has changed that has caused this error. I am wondering if it is a Winter '21 update? Additionally, if I am an admin user, this LWC still functions correctly. It's when I am logged in as a regular user when this error occurs. This is the print out from the console from my LWC Controller.

How do I go about fixing this in either my org settings / in my class code? I will upload code if need be.

Additionally, I have consulted this related post: "You do not have access to the Apex class named ...": cannot find the cause . Although I haven't gotten a clear solution that can help me out (I am new to Salesforce).

A step by step will be very much appreciated!

EDIT: I saw this https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_lc_restrict_apex_guest_users.htm

It seems that @AuraEnabled classes will be inaccessible to regular users. How does one turn this off OR how do I let users access @AuraEnabled classes?

2 Answers 2

4

Assign the class to the users' profiles or to a permission set (and assign it to the designated users).

Bear in mind that this is the kind of work you have to do to limit the user's access to any classes they are not supposed to run.

Which means that if you have two sets of users that run different components, it is recommended that you create two permission sets for those accesses.

5
  • Hello! Thank you! One question: how does one "assign the class to the user's profile"? I understand how to work with permission sets, but I am curious about that first suggestion.
    – Peabrain
    Commented Oct 21, 2020 at 18:31
  • Much like in the permission set setup, there's a "Apex Class Access" section under the profile. There, you can assign classes that users with that specific profile can access, just like in a permission set. Commented Oct 21, 2020 at 18:39
  • 1
    It's a good thing that you are already familiar with Permission Sets. I'd use those instead of profiles. Commented Oct 21, 2020 at 18:39
  • @RenatoOliveira Do I also need to give access to subsequent classes? For example, if my LWC calls class_1 and foo enqueues queueables class_2 and class_3. Do I need to only add class_1 to the permission set or do I also need to add both class_2 and class_3?
    – Bahman.A
    Commented Sep 2, 2021 at 18:20
  • I think you don't need to add the other two. Commented Sep 3, 2021 at 11:46
6

With the Winter '21 release, Salesforce is enfofcing the critical update Restrict Access to @AuraEnabled Apex Methods for Authenticated Users Based on User Profile (Update, Enforced)

Documentation can be found here

In the affected profile (Or Permission Set)

enter image description here

Or in this section on the profile

enter image description here

If you click the 'Edit' button, you can select the classes you would like enabled or not for the given profile.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .