You need to sign in to do that
Don't have an account?
Francesco Sciuto
Community: create direct login link for internal CRM instance users
Hello,
I am currently in the process of overriding the native Community login flow of SalesForce with our own custom-made. The custom login flow for Community users (external to our organization) works fine but of course our internal users, if they want to access the community, cannot use the same flow since they need to go to login.salesforce.com (or any othe rinstance URL such as https://na2.salesforce.com), enter their credentials to login to the CRM org and then access the community from there.
Therefore in the login screen for the Community, besides the form to enter the credentials for Communtiy external users, I would like to add a link that redirects our internal users to the CRM login page and still keeping track of the Community URL they were browsing when they were prompted to login.
In order to achieve this, I added the folliwing span element to the SiteLogin component:
https://na2.salesforce.com/servlet/networks/session/create?site=0DM400000003deffa&refURL=[some ref url]
That correctly redirects internal users to the SF CRM login screen. I guess this link is machine-generated since it works without modification in both sandbox and production instances. How can I programmaticaly create such URL? Thanks
I am currently in the process of overriding the native Community login flow of SalesForce with our own custom-made. The custom login flow for Community users (external to our organization) works fine but of course our internal users, if they want to access the community, cannot use the same flow since they need to go to login.salesforce.com (or any othe rinstance URL such as https://na2.salesforce.com), enter their credentials to login to the CRM org and then access the community from there.
Therefore in the login screen for the Community, besides the form to enter the credentials for Communtiy external users, I would like to add a link that redirects our internal users to the CRM login page and still keeping track of the Community URL they were browsing when they were prompted to login.
In order to achieve this, I added the folliwing span element to the SiteLogin component:
<span>Our internal Employee? Login <a href="{! EmployeeLoginURL }">here</a></span>And in the SiteLoginController (that controls SiteLogin):
global PageReference EmployeeLoginURL { get { String startUrl = System.currentPageReference().getParameters().get('startURL'); String sfBaseUrl = System.URL.getSalesforceBaseUrl().toExternalForm(); return new PageReference(sfBaseUrl + '/login?' + startURL); } }This code does not work for the following reasons:
- In some cases EmployeeLoginURL is the base URL of our Community instead of our CRM instance
- In some cases EmployeeLoginURL is treated as a relative path and added to the root path of the communityand generates a page not found error;
- The login parameter is (indeed) not a valid one.
https://na2.salesforce.com/servlet/networks/session/create?site=0DM400000003deffa&refURL=[some ref url]
That correctly redirects internal users to the SF CRM login screen. I guess this link is machine-generated since it works without modification in both sandbox and production instances. How can I programmaticaly create such URL? Thanks
It is the same login framework and everything should work (of course you have to make sure that they have access to the pages)