Topic-icon Custom Facebook button to login if account exists

Active Subscriptions:

None
11 years 7 months ago #48160 by matgray87
Hi Alex,

From the sign in page, that's the value it returns. From the Register/Join Us page, it doesn't return anything which is weird?

RE the login redirect... once the login process has gone through, it directs the user to their logged in profile, so they can fill in the missing information that isn't collected from Facebook, so it really needs to stay as that and not a public page... Is there somewhere I can manually add an Itemid in the back-end to force it? Obviously then every time I update the component, I'll have to make the same changes again...

Thanks,
Matt
The topic has been locked.
Support Specialist
11 years 7 months ago #48170 by alzander

was that, when automatically registering an account, and sending a user-activation email, the user is redirected to the sign in page, but with the wrong itemID, so where can I add that in?

Followed by:

RE the login redirect... once the login process has gone through, it directs the user to their logged in profile, so they can fill in the missing information that isn't collected from Facebook, so it really needs to stay as that and not a public page...

In the first case, you mention that the user is getting sent a user-activation email. In that case, JFBConnect *can not* log them in, which means that they can't be sent to the logged in profile page to fill in missing information, in which case the New User Redirection can't be to that registered-only page. There's some disconnect between what we're discussing here. Help me understand it more.

Of course the "Returning User Redirection" setting can be to the profile page. That shouldn't be a problem since they should have already activated their account.

From the sign in page, that's the value it returns. From the Register/Join Us page, it doesn't return anything which is weird?

That is very strange. That session variable is the first thing JFBConnect does during the login process. That's also how we determine where to send the user when the New User or Returning User redirection setting is "Same Page", which is used by many sites.. so it *should* return the proper thing as that session variable is used even later in the same function in the following line:
$redirect = $loginRegisterModel->getLoginRedirect($provider);
Can you try disabling caching and/or SEF URLs (though it doesn't seem like they're on) and testing again? Also, if you have any other pages with the Facebook login button, try from there to see what the redirect is just to help narrow things down.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 7 months ago #48187 by matgray87
Hi Alex,
Hope you've had a good weekend!

I've added the login to the bottom of all the item pages, and using $redirect = JFactory::getApplication()->getUserState('com_jfbconnect.login.return', 'index.php'); returns the page that I tried to sign in from (using the SEF URLs) ( e.g. here ). However, the sign in page returns the non-SEF URL as above, and the register page returns '/register' as you'd expect. It's just the sign-in page which returns the non SEF url...

If I can get that to return '/sign-in' then I assume I can just create an if statement to say if $redirect == '/sign-in': ....... would that work?

I understand that:

In the first case, you mention that the user is getting sent a user-activation email. In that case, JFBConnect *can not* log them in, which means that they can't be sent to the logged in profile page to fill in missing information, in which case the New User Redirection can't be to that registered-only page. There's some disconnect between what we're discussing here. Help me understand it more.


What I meant was that the user is redirected to the sign-in page (as expected, as the user doesn't have a log in), but they are returned to a sign in page with the wrong Itemid... where is the line of code that sends them back to the sign in page, so I can force an itemID on the end?

Thanks,
Matt
The topic has been locked.
Support Specialist
11 years 7 months ago #48194 by alzander

What I meant was that the user is redirected to the sign-in page (as expected, as the user doesn't have a log in), but they are returned to a sign in page with the wrong Itemid... where is the line of code that sends them back to the sign in page, so I can force an itemID on the end?

That's in Joomla itself, not JFBConnect. I'd recommend, instead of using JFBConnect to redirect them to a registered page, to just configure the New User Redirection to be the Sign In menu item you've created instead of redirecting to a registered page and then having Joomla redirect them to the Itemid-less sign-in page.

As for the link detection, can you tell me what the sign-in URL is so we can see what it looks like before the social login button is clicked? Not sure why it would come back as non-SEF when all the others come back that way.. unless it's non-SEF to begin with.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 7 months ago #48199 by matgray87
Yep, no worries... the sign-in page is located HERE and you'll need to add the invitation code in as YANDV to display the buttons...

I've set the log-in redirect to be '/sign-in' and also played around with SH404SEF to force the Itemid I want, so now that works fine (I think!).

SEF URLs are set for all pages, so no idea why it wouldn't pick up for the sign-in...

Thanks again,
Matt
The topic has been locked.
Support Specialist
11 years 7 months ago #48218 by alzander
Definitely strange. JFBConnect is setting the return_url string on that page to:
aW5kZXgucGhwP29wdGlvbj1jb21fdXNlcnMmdmlldz1wcm9maWxl
Which, when decoded, sure enough goes to index.php?option=com_users&view=profile

Can we remove sh404SEF from the equation altogether, just for testing purposes? Turn it off and check the URL in the address bar when on the sign-in page (or whatever the non-SEF version is). Then, try the code modification and check that the return variable set in the session is correct. If so, try enabling Joomla's SEF and see if that sets the Itemid properly. If so, we'll need to narrow down why sh404SEF is reporting a different URL to us when the sign-in page is rendered.

Alex
The topic has been locked.
Active Subscriptions:

None
11 years 7 months ago #48233 by matgray87
OK - here we go:

From the sign in page:

SH404SEF enabled:
Link = yandv.mattgraydesign.co.uk/sign-in
Return = index.php?option=com_users&view=profile

SH404SEF disabled:
Link = yandv.mattgraydesign.co.uk/index.php?opt...iew=login&Itemid=487
Return = index.php?option=com_users&view=profile

Joomla SEF enabled:
Link = yandv.mattgraydesign.co.uk/index.php/sign-in
Return = index.php?option=com_users&view=profile

It's always the same regardless...

From the registration page:

SH404SEF enabled:
Link = yandv.mattgraydesign.co.uk/register
Return = /register

SH404SEF disabled:
Link = yandv.mattgraydesign.co.uk/index.php?opt...istration&Itemid=488
Return = /index.php?option=com_users&view=registration&Itemid=488

Joomla SEF enabled:
Link = yandv.mattgraydesign.co.uk/index.php/register
Return = /index.php/register

So I have no idea...

I suppose I could just use:
else 
					{ 
					  $fromwhere = JFactory::getApplication()->getUserState('com_jfbconnect.login.return', 'index.php');
					  if ($fromwhere != '/register') {
					 $app->enqueueMessage('Sorry but you must...'); 
					 $app->redirect('index.php'); 
					  }
					  else {}
					}

This actually works, and then allows people to sign in from the Sign In page if they already have an account (if not it throws out the message), and if they try and sign in from the Register page (once the Invitation code has been entered), it creates an account.

This way, I don't need an invitation code to be in place on the Sign In page...

Phew!

Last thing that's causing me problems now, is that the user is sent the 'Activate your email address' email, and once the link has been clicked, it's not coming up as activated in the back end, even though they are sent a message saying your account has successfully been activated and now needs to be approved by an administrator. Doesn't the administrator only have to enable the user, not activate them as well?

Thanks,
Matt
The topic has been locked.
Support Specialist
11 years 7 months ago #48245 by alzander
That's completely bizarre. I really don't have a good reason as to why the URL is coming back like it is from that one specific page. I think your solution is the right solution though, and shouldn't give you any problems. If, however, you want me to investigate further, I gladly can.. but I don't think the result will be any different than what you implemented.

Last thing that's causing me problems now, is that the user is sent the 'Activate your email address' email, and once the link has been clicked, it's not coming up as activated in the back end, even though they are sent a message saying your account has successfully been activated and now needs to be approved by an administrator. Doesn't the administrator only have to enable the user, not activate them as well?

Joomla has 2 different activation modes.. User and Admin. It sounds like you have them both enabled to where the user has to confirm their email address and the admin has to approve them. You can modify those settings in the User Manager -> Options tab. You can also configure JFBConnect to not require activation at all for social accounts, while leaving it enabled for standard registrations, by enabling the "Skip Joomla Activation" setting.

I hope that helps,
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 7 months ago #48258 by matgray87
Hi Alex,

OK, I'll leave it as it is then... at least that works perfectly as I want it, so no worries on any further investigation... Problem 1 solved!

I understand the principle behind this:

Joomla has 2 different activation modes.. User and Admin. It sounds like you have them both enabled to where the user has to confirm their email address and the admin has to approve them. You can modify those settings in the User Manager -> Options tab. You can also configure JFBConnect to not require activation at all for social accounts, while leaving it enabled for standard registrations, by enabling the "Skip Joomla Activation" setting.


But why when the user Activates through their email address, does it then not show activated in the back-end? Is that because Joomla then expects admin then to again activate?

Ideally, the process I want is that the user Activates their own account (either registering through social or the normal form), and then it will show as activated back-end, but it won't be enabled. I then want the admin to Enable the user...

Is that possible?

Thanks,
Matt
The topic has been locked.
Support Specialist
11 years 7 months ago #48275 by alzander

But why when the user Activates through their email address, does it then not show activated in the back-end? Is that because Joomla then expects admin then to again activate?

If activation is set to "Admin", the behavior you describe is correct, I believe. There's 2 activations that have to occur in that state: the user for their email and the admin to enable. I'm not sure how the columns specifically behave. My best recommendation is to test the standard Joomla registration process and compare to JFBConnect's, which should behave similarly.

I hope that helps explain,
Alex
The topic has been locked.