Salesforce Sites do not provide a global object to access logged in user details. To get the details of the current user and pass it to AptEdge, we’ll need to create an Apex class.

SiteUserInfo.@RestResource(urlMapping='/siteUserInfo')
global with sharing class SiteUserInfo {
global class UserInfoDTO {
public String userId;
public String name;
public String email;
public String userType;
public Boolean isAuthenticated;
}
@HttpGet
global static UserInfoDTO getUserDetails() {
UserInfoDTO result = new UserInfoDTO();
result.userId = UserInfo.getUserId();
result.name = UserInfo.getName();
result.email = UserInfo.getUserEmail();
result.userType = UserInfo.getUserType();
result.isAuthenticated = result.userType != 'Guest';
return result;
}
}
Guest users and JavaScript code running on your Salesforce Site can’t access your new Apex class by default, so we must explicitly allow public access.


SiteUserInfo, to the Enabled Apex Classes list, then choose Save.