Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global class UrlRewriterClass implements Site.UrlRewriter {
- //Maps a user-friendly URL to a Salesforce URL
- global PageReference mapRequestUrl(PageReference friendlyUrl) {
- System.debug('UrlRewriterClass.mapRequestUrl: ' + friendlyUrl);
- if(AppController.isPublicURL(friendlyUrl)) {
- return null;
- } else {
- String url = friendlyUrl != null ? friendlyUrl.getUrl() : null;
- String regionID ='';
- String AU = 'AU_';
- Boolean GuestUser = TRUE;
- String CUSTOMER_PROFILE_NAME = 'AU Guest User';
- Id profileId=userinfo.getProfileId();
- String profileName=[Select Id,Name from Profile where Id=:profileId].Name;
- if (url.containsIgnoreCase('AU_Mb')){
- regionID = 'Mb';
- GuestUser = FALSE;
- }
- else if (url.containsIgnoreCase('AU_Cb')){
- regionID = 'Cb';
- GuestUser = FALSE;
- }
- if (GuestUser == FALSE) {
- String regionCode = '';
- String region = url.toLowerCase().substringAfter(AU.toLowerCase());
- if(region != null && region.length() > 0) {
- regionCode = '?sc=' + region;
- }
- return new PageReference('/apex/LoginTo_au_' + regionID + regionCode);
- } else {
- if (profileName == CUSTOMER_PROFILE_NAME) {
- return new PageReference('/apex/HomePage');
- } else {
- return new PageReference('https://LoginToAU.force.com/AU/');
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment