+ Start a Discussion
SwapnilSwapnil 

Site.login problem

I am using Site.login with the start Url as null. Once the user is successfully logged in I want to redirect it to some page. I need to check if the user is successfully logged in or not? I am currently checking if the Site.login return null then it is unsuccessful. And then I try to redirect.

 

The page is getting redirected but the user is not logged in. How can I check if the user is actually logged in.....

BulentBulent

If you don't pass the start url after login user will be taken to the site home page. 

If you pass the start url and if the login is successful then user will be taken there if the login is not successful then visitor will remain on the same page.

so you have two options

1- if site login fails then visitor will remain on the same page and won't be redirected to the start url. So you might want to pass the start url

2- don't pass start url and check on the user type on the site home page. If the user type is 'Guest' then it means anonymous access. But this might mean that you won't be caching the home page. I would recommend option 1.

 

SwapnilSwapnil

The problem with option 1 is that I cannot pass more than 1 parameter to the startUrl. So after successful login I will create my own new URL and will redirect the user to that page. Thats what I have thought.

 

If there is any way to pass more than 1 parameter to the startUrl I don't need to do all this. Please let me know what you think about this and thanks for your reply.

BulentBulent

can you try passing more than parameters again? It was a bug that the fixed is deployed last night.

SwapnilSwapnil

Sure I will try that right away..... Will respond with what I find.

SwapnilSwapnil

It did not work for me. It is still taking just 1 parameter.

 

Do I need to refresh my org or something to get the updated org. I dont think so but still making it sure....

BulentBulent

no changes required on your side. We'll look in to this and post an update

RyanGuestRyanGuest

 

 

return Site.login(username, password, '/home/home.jsp?a=1&b=2&c=3');

 

 

 

 

 

String startUrl = System.currentPageReference().getParameters().get('startURL');
return Site.login(username, password, startUrl);

 with a URL like:

 

http://mysite.force.com/SiteLogin?startURL=/home/home.jsp?a=1&b=2&c=3

 

Then System.currentPageReference().getParameters().get('startURL') is going to return "/home/home.jsp?a=1" and not "/home/home.jsp?a=1&b=2&c=3" like you might expect (because those are treated as different query parameters). To get the values of b and c you would get to use:

 

 

System.currentPageReference().getParameters().get('b');

 

 

 

 

 

SwapnilSwapnil

So I tried

 

String startUrl = '/hompage?a=' + value_a + '&b=' value_b;

site.login(username, pwd, startUrl);

 

It just logged in with the 1st parameter. value_a and value_b are dynamic values which I want in my url.

SwapnilSwapnil

I tried this as well

 

return Site.login(username, password, '/home/home.jsp?a=1&b=2&c=3');

And this also returned me ***.com/home/home.jsp?a=1
SwapnilSwapnil

Even today I tried with Ryan's solution but the result is same the page is redirected correctly but with only 1st parameter.

 

So what I thought was after successful login I will create a new pagereference where I want it to land. But this approach took me to the correct page but the user didnt get logged in.

zaidyzaidy

I think this problem has come back after Summer 10 release. Has anyone else experienced it again?

zaidyzaidy

We are experiencing this issue again. Has any one else experienced this issue after Summer 10 release?

AddisonAddison

@zaidy - Is the site on one of NA1, NA6, or NA7?  Those are the instances that have been upgraded this past Friday evening.  Did you encounter this problem before Friday?

zaidyzaidy

Hi Addison, 

We didn't have this problem before Friday (day time UK), it appeared on Saturday (UK time) just after the upgrade. We are on NA7 and were aware of the upgrade happening on Friday night USA time. 

 

AddisonAddison
Hi zaidy, we have identified the issue and are working on a fix for it. Thanks for your help identifying this issue.
zaidyzaidy

 

Hi Addison, 
Thank you for that. As a work around, we have been advised to change the pages API version to 19 manually (we are also changing the controllers version to 19 just in case). Which seems to be working at list on development org. I keep you posted.