无法登录Experience Cloud站点:无LightningLoginFormController访问权限
Experience Cloud登录报错「无LightningLoginFormController访问权限」的排查方案
问题详情
- 报错信息:登录Experience Cloud站点时,反复提示「You do not have access to the Apex class named LightningLoginFormController」
- 已排查操作:
- 为所有用户配置文件添加了该Apex类的访问权限
- 测试过「with sharing」与「without sharing」修饰符,问题未解决
- 关联Apex类代码:
global class LightningLoginFormController { public LightningLoginFormController() { } @AuraEnabled public static String login(String username, String password, String startUrl) { try{ ApexPages.PageReference lgn = Site.login(username, password, startUrl); aura.redirect(lgn); return null; } catch (Exception ex) { return ex.getMessage(); } } @AuraEnabled public static Boolean getIsUsernamePasswordEnabled() { Auth.AuthConfiguration authConfig = getAuthConfig(); return authConfig.getUsernamePasswordEnabled(); } @AuraEnabled public static Boolean getIsSelfRegistrationEnabled() { Auth.AuthConfiguration authConfig = getAuthConfig(); return authConfig.getSelfRegistrationEnabled(); } @AuraEnabled public static String getSelfRegistrationUrl() { Auth.AuthConfiguration authConfig = getAuthConfig(); if (authConfig.getSelfRegistrationEnabled()) { return authConfig.getSelfRegistrationUrl(); } return null; } @AuraEnabled public static String getForgotPasswordUrl() { Auth.AuthConfiguration authConfig = getAuthConfig(); return authConfig.getForgotPasswordUrl(); } @TestVisible private static Auth.AuthConfiguration getAuthConfig(){ Id networkId = Network.getNetworkId(); Auth.AuthConfiguration authConfig = new Auth.AuthConfiguration(networkId,''); return authConfig; } @AuraEnabled global static String setExperienceId(String expId) { // Return null if there is no error, else it will return the error message try { if (expId != null) { Site.setExperienceId(expId); } return null; } catch (Exception ex) { return ex.getMessage(); } } }
针对性解决步骤
1. 重点检查站点访客用户的权限
Experience Cloud登录页面的触发者是站点访客用户(Site Guest User),而非普通内部用户。必须确保该用户对应的配置文件拥有LightningLoginFormController的访问权限:
- 操作路径:设置 → 数字体验 → 所有站点 → 选中目标站点 → 点击「工作区」→ 「管理」→ 「访客用户」→ 查看其关联配置文件 → 编辑配置文件的Apex类权限,添加该类的访问权限。
2. 确认类与方法的访问修饰符
你的类已使用global修饰,满足外部访问要求,但需注意:被Aura组件调用的方法需保证权限足够(当前代码中@AuraEnabled修饰的方法权限均达标,此点可作为二次验证)。
3. 验证网络(Network)关联权限
代码中getAuthConfig方法调用了Network.getNetworkId(),需确保访客用户所在网络与当前站点网络一致,且该用户拥有对应网络的访问权限。
4. 检查登录组件的访问权限
若登录页面是自定义Aura组件,需确保组件允许访客用户访问:
- 操作路径:设置 → 闪电组件 → 找到登录组件 → 编辑权限,勾选访客用户配置文件的访问权限。
5. 清除缓存并重新部署
权限变更后可能存在缓存延迟,可通过以下操作确保生效:
- 执行匿名Apex:
System.clearCache(); - 若为生产环境,重新部署Apex类与相关组件。
内容的提问来源于stack exchange,提问作者0x00020905
相关产品推荐
相关产品推荐

