So i'm developing a Drupal 8 site and I'm using the 'simple fb connect' module.
I've almost literally copied the code from Drupal to add a custom role to my new user and to get the facebook data and link them to my custom fields. Everything works fine until I actually try to register or login.
First let me explain how the flow works, so when you try to log in or register, you get redirected to the '/management' page ( This with the module 'Redirect after login' module). This page is only allowed for users with the role jobseeker. All this works perfectly fine with the drupal login and registration. Only with the facebook module, something goes wrong.
Judging by my log messages this is what happens when I try to login with the simple fb connect module.
The session opens normally, if the user hasn't already have an account, it makes a new one. The user already has the role 'jobseeker' assigned.
There's a redirect to the page '/management' (everything is fine up until here)
The page '/management' gets an error 'Access Denied', if I check my logs, drupal tries to access this page as an anonymous user... even though the user is logged in.
When refreshing the page, suddenly i'm logged in and have the role jobseeker assigned
This problem occurs not every time and at very random moments, sometimes after 3 login attempts and sometimes after 8.. Can someone help me figure out how I suddenly lose my user's role or how to avoid this..
SOLVED:
The module "Simple fb connect" conflicts with the module "Redirect after login". So I removed the module "Redirect after login" and just added the "Rules" module, to set my login-destination with a rule.
Related
I'm still new to CI and PyroCMS, and am trying to implement a Facebook login using the Social module in a custom module, which looks like it does everything I want, but I'm clearly missing some basics (I can't find any documentation other than the brief readme)!
So far, I've watched the intro video, and have enabled Facebook successfully. I can connect via FB and see FB listed in /social/linked, but some confusion exists in my mind between the two user groups I've got: admin and user.
The flow I'm trying to construct is:
user arrives at the site and is presented with a survey
user fills in the survey, then is asked to signup (I understand that this is unconventional)
/signup has a facebook connect button, supplied by the social module
user clicks the connect button, and grants permission in facebook's popup window
user should be directed back to /signup, (or maybe redirected to /user/registration) with some details filled in from facebook (eg. email, name)
on submit, user should be added to the users table, as a member of the 'users' group (not admin) with no email activation required
an email is sent, thanks page is displayed
on returning to the site, the user should access their on-site profile using facebook connect.
I've read a bunch of threads on the subject, which have shaped these expectations...
Here's where I'm at:
user arrives, fills in survey, clicks the connect button
user is redirected to the homepage, which displays a standard page (not handled by my module). I need to return to /signup!
Based on this, I've tried setting:
$this->session->set_userdata('redirect_to', '/signup');
in what I believe is the correct controller method (checks to see if the user is logged in before sending the email, then calls template build to display the social buttons), to no avail.
(edit: I now see that the code above relates to the user module, not the social module.. maybe i can transplant some changes...)
My questions:
am i on the right track, or going about this the wrong way?!
am i right in thinking that the FB account will be matched with an existing user if the email addresss exists in the system?
I have only one FB account, which I is authorised for the app, and I'm using to connect with as a user - will this work, or do I need a separate FB account to test as user?
Other notes:
I am testing the site in Chrome, logged in as admin in Firefox.
Facebook is my testcase, I'm looking at supporting FB, LinkedIn, google and Twitter eventually.
Phew! Grateful for any feedback, Tim
I will try to answer some of your questions since i'm currently experimenting with the exact same social module as well and with some addons to it.
am i right in thinking that the FB account will be matched with an
existing user if the email addresss exists in the system?
Yes you are. I checked it myself while troubleshooting the fact that my google (gmail address) could'nt connect while my hotmail (registered email) could. You will have to sync your emails in all your social sites, change the loginsystem (allowing username login for example) or manually connect multiple emails in your account settings..
I have only one FB account, which I is authorised for the app, and I'm using to connect with as a user - will this work, or do I need a separate FB account to test as user?
I suggest u let someone with another FB account test the system (better save then sorry) but in my case I didn't have any troubles using other (normal) accounts to log in.
am i on the right track, or going about this the wrong way?!
This was your first question, but I'll answer this as the last on since I didn't test is myself:
The Facebook App has a setting called "Site URL". This is the url to which will be redirected. Simply change it to the page you wish it to be. You can also try to change the following lines in social/controllers/social.php:
Line 245 (redirect: user is logged in after FB connect)
redirect($this->input->get('success_url') ? $this->input->get('success_url') : 'social/linked');
Line 283 (redirect: user has to fill in some additional fields to complete registration)
redirect('users/register');
Good luck!
The intro video shows off the entire extent of the social module. Frontend registrations, frontend user account linking, and backend account linking for the entire system.
If you wish to integrate custom functionality, custom user flows and other stuff as listed in your question then you will need to do a little custom work with the module. Hack it, extend it, send in some pull requests, whatever, but sadly it cannot do "everything to integrate with everywhere ever" out of the box. :-/
I have created a website that allow user use facebook login system to regist and login. The system runs good. It can use single sign-on to login the system, so the user does not need to input the username and password --- until yesterday.
One of teammate find that he stucked in the login system, and the single sign-on does not function anymore. The user need to input account detail whatever they have login facebook or not. The most funny thing is, after the user login in facebook login system, it does not redirect the user to the "next" url or redirect them to facebook.com (mostly this means login system setting had eror). It just stuck in the facebook server with empty blank page.
This is the link what I stuck in....
https://www.facebook.com/login.php?login_attempt=1&fbconnect=1&display=page&next=(next url)&req_perms=publish_stream%2Cread_stream%2Cemail%2Cuser_photos&legacy_return=1
without session code, and does not have any reply.
I want to know if I have set something wrong...
Use of legacy_return was deprecated almost a year ago with the migration to OAuth2, and the endpoints were finally shut down today. Please update your integration per https://developers.facebook.com/docs/concepts/login/
I'm trying to implement a 'one-click' Facebook registration process on my site. I'm getting extremely wound up because on other sites with what I want, they just have a 'Register with FB' button which they click and they're instantly given an account.
But if I go to the FB documentation for Registration its talking about displaying an entire form in an iframe with values prefilled (which none of the other websites seem to need?).
I have a FB Login button, which gave me a popup dialog asking to auth permissions and then I added a registration-url to send them to my registration page if they don't have an account (not sure how FB knows this? I guess it means not authorised?). So then how do I authorise the app with one click on the registration page?
All I want to do is initiate a request on my server to make the registration using the FB user's email and user_id. I can store these in MySQL.
Click Register > Authorise app. Whenever you want to log into the system you just click Login (saving you entering an email and password for registering and logging in).
Am I missing something? I can't seem to see this anywhere?
I can't understand what I'm missing here.
use php sdk to access the users info after the dialog. something like below, but probally want to check database for exists.
$email=$user_profile[email];
$uid=$user_profile[id];
$sql = 'INSERT INTO mydatabase (`id`, `email`) VALUES (\''.$uid.'\', \''.$email.'\');';
$insert=mysql_query($sql) or die ('Error! in Insert '.$uid.' SQL');
OK, so my application works fine and dandy, but I recently discovered a problem when a user is logged in "as a page". When the user is logged in as a page and goes directly to the app base url... i.e. apps.facebook.com/... it correctly identifies that the user object is incorrect and sends the user to:
https://www.facebook.com/login/roadblock.php?target_url=...
This makes the user login as the actual FB user, and it works well.
But it does not do this on the app's page tab. It just redirects to:
https://s-static.ak.facebook.com/platform/page_proxy.php?v=4
Is there a command or function in the PHP SDK that can check if the user is using as a page, and redirect them to the referred page?
There is currently no way to check if user logged in as page due to fact that Facebook doesn't provide this information and prompting to switch back to usage of regular Facebook account on any interaction with applications.
I have added Facebook Connect to my application via the JavaScript SDK. I'm using Spring Security (this is a grails app) and I have added code that when someone clicks the FB Connection button to login, I manually authenticate them against their user account and everything gets wired up appropriately. I have 2 questions:
When a user first logs in with FB and I don't have an account for them, I create an account for them with their FB info, generate a random password, and use their email for their login name. If the user then uses the regular login form instead of the FB button to sign in, how do I sign them in to FB as well?
Every time the user clicks the FB Connect button, the popup window shows up. If they are already authenticated, it just goes away and then my web site redirects correctly. How do I keep the popup window from showing up in this case?
Thanks
To you first question, the user might be connect on Facebook when landing on your page after registration. So you can rely on the Javascript SDK to help you out.
See here: http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus
To your second question, I think you can't, except you might get a work around if you use the Javascript SDK mentioned for the first question!
This is how I did it for moviezine.se and it works just fine, but it might be a little irritating to be logged in without asking for it when you come back a few days later. Then there is the use case of the logout: if you are automatically logged in, are you automatically logged out too; and if not, what if your Facebook session is replaced by your girlfriend's one who is also a user on your site! :)