3

Can't we use JanRain for Community Users log-in. I am getting error as

"AuthorizationError?ErrorCode=NO_ACCESS&ErrorDescription=User+was+a+portal+user"

The custom log-in page is working for Internal users.

Code is here:

global class AuthConnectHandler implements Auth.RegistrationHandler{
global User createUser(Id portalId, Auth.UserData data){
    system.debug('***auth.userdata:'+data);
    //This code is to fetch only one Community User for testing 
    User externalUser=[select firstName,id,lastName,email from user where username like '%ThisisRSN%'];       
    update(externalUser);//updating nothing   
    return externalUser;   
}

global void updateUser(Id userId, Id portalId, Auth.UserData data){
/*
    system.debug('***auth.userdata:'+data);
    User u = new User(id=userId);
    u.email = data.email;
    u.lastName = data.lastName;
    u.firstName = data.firstName;
    String alias;
    if (data.username<>null)
        alias = data.username;
    else
        alias = data.fullName;
    //Alias must be 8 characters or less
    if(alias!=null&&alias.length() > 8) {
        alias = alias.substring(0, 8);
    }
    u.alias = alias;
    update(u);
*/
}        
}

Description in below diagram: enter image description here

P.S.: I am using JanRain Developer account for learning this feature. I hope, it don't have this type of limitation.

  • We don't have JanRain as tag :P. – Rajendra Singh Nagar Jun 17 '14 at 9:13
  • It appears there is some documentation.. Are you past the Google searches? janrain.com/blog/… – EricSSH Jun 24 '14 at 20:44
  • @EricSSH, Yes i have google everything... Its not working as it is said. Also, there is no place where documentation for JanRain implementation in Salesforce is Given. – Rajendra Singh Nagar Jun 25 '14 at 10:30
  • I tried to check this issue again. Steps i followed: 1. Used the Test-Only Initialization URL as shown below: login.salesforce.com/services/auth/test/00D90000000vLeDEAU/… Now, if try to give my internal user credentials, it is allowing me to login. However, if i give community user credentials, it is not allowing me to login. @metadaddy♦ any comments on this...! – Rajendra Singh Nagar Jul 1 '14 at 15:52
  • Are portal users suppose to be able to access it? I'm not familiar with JanRain and how to acts with portal users – EricSSH Jul 1 '14 at 15:54
2

The problem is that, when the response comes back from Janrain, there's nothing to indicate that it is an external user signing in, so the platform thinks you're trying to log an external user (what used to be a portal user) into the org itself.

So, to fix, you need to include a community query parameter in the tokenUrl for Janrain, like this:

// In Janrain widget code
// tokenUrl = singleSignOnCallbackURL + '?flowtype=sso&community=' + encodeURIComponent(communityURL)
janrain.settings.tokenUrl = 
    'https://login.salesforce.com/services/authcallback/00Dd0000000e1KYEAY/JanrainProvider?' +
    'flowtype=sso&'+
    'community=' + encodeURIComponent('https://patdev-developer-edition.na14.force.com/developers');
  • Thanks very much metadaddy...:) I tried this out. But , even though session id is generated, user is not navigated to landing page. I can see that session id is generated with no error, but user is not navigated to landing page. Can you pls help with this? – Rajendra Singh Nagar Jul 13 '14 at 20:32
  • Did you follow the instructions in the Communities Implementation Guide for customizing the login page? You need to edit the controllers and pages for both login and landing. – metadaddy Jul 15 '14 at 12:25
  • Yes, i checked the communities implementation guide. I was thinking that there might be some default parameter that we can specify for retURL. As a fix, i have updated my custom login page controller. Steps i followed, (knowing session id is generated, but user in not redirected to landing page) Check for the user in login page controller. 1. If he is community guest user, do nothing. 2. If session id is genereated, then the user will be community user. Redirect the user to landing page. Now, the functionality is working as expected. Thanks @metadaddy for your help and response :) – Rajendra Singh Nagar Jul 15 '14 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.