Guest User

Untitled

a guest
Feb 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. global class UrlRewriterClass implements Site.UrlRewriter {
  2.  
  3. //Maps a user-friendly URL to a Salesforce URL
  4.  
  5. global PageReference mapRequestUrl(PageReference friendlyUrl) {
  6. System.debug('UrlRewriterClass.mapRequestUrl: ' + friendlyUrl);
  7.  
  8. if(AppController.isPublicURL(friendlyUrl)) {
  9. return null;
  10.  
  11. } else {
  12.  
  13. String url = friendlyUrl != null ? friendlyUrl.getUrl() : null;
  14. String regionID ='';
  15. String AU = 'AU_';
  16. Boolean GuestUser = TRUE;
  17. String CUSTOMER_PROFILE_NAME = 'AU Guest User';
  18. Id profileId=userinfo.getProfileId();
  19. String profileName=[Select Id,Name from Profile where Id=:profileId].Name;
  20.  
  21. if (url.containsIgnoreCase('AU_Mb')){
  22. regionID = 'Mb';
  23. GuestUser = FALSE;
  24.  
  25. }
  26. else if (url.containsIgnoreCase('AU_Cb')){
  27. regionID = 'Cb';
  28. GuestUser = FALSE;
  29. }
  30.  
  31. if (GuestUser == FALSE) {
  32.  
  33. String regionCode = '';
  34. String region = url.toLowerCase().substringAfter(AU.toLowerCase());
  35.  
  36. if(region != null && region.length() > 0) {
  37. regionCode = '?sc=' + region;
  38. }
  39.  
  40. return new PageReference('/apex/LoginTo_au_' + regionID + regionCode);
  41.  
  42. } else {
  43.  
  44.  
  45. if (profileName == CUSTOMER_PROFILE_NAME) {
  46. return new PageReference('/apex/HomePage');
  47. } else {
  48.  
  49. return new PageReference('https://LoginToAU.force.com/AU/');
  50. }
  51.  
  52. }
  53. }
  54. }
  55. }
Add Comment
Please, Sign In to add comment