function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
iceberg4uiceberg4u 

Redirecting users after login

Hi we have users with profiles cloned from Partner Portal.All of them login though the Sites.Now I have a need of redirecting these users to different pages after successful login on the basis of their profiles.

 

I have performed it like this:->

 

In the SiteLoginController I have done something like this:->

 public PageReference login() {

Id profileId = UserInfo.getProfileId();

 if(profileId == x)

 startURL = '/asd';

else if(profileId == y)

 startURL ='/asdwer';

 

return Site.login(username, password, startUrl) ;

 }

 

Now the problem is a usability issue.When a first time user is made ,he or she would be changing his/her password when he logs into the first time.This changing password page or module is bypassed by my code.

 

Is there a method of achieving this?

 

Thanks,

 

Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess

I would suggest another method.  Allow these users to login and go to one page ( no redirect) so that the change password page is not bypassed.

 

Then on that page, you would define an action 

 

<apex:page controller="somecontroller" action="{!myredirect}" > </apex:page>

 

 This action can then look at their profile and send them to the correct page for their profile.  All of this happens after they are logged in, so you keep the password stuff inplace.

 

 

All Answers

Ron HessRon Hess

I would suggest another method.  Allow these users to login and go to one page ( no redirect) so that the change password page is not bypassed.

 

Then on that page, you would define an action 

 

<apex:page controller="somecontroller" action="{!myredirect}" > </apex:page>

 

 This action can then look at their profile and send them to the correct page for their profile.  All of this happens after they are logged in, so you keep the password stuff inplace.

 

 

This was selected as the best answer
BulentBulent
we will also fix this in the future release so that change password will carry over the StartUrl parameter