Replacing drupal registration and login using facebook login

I am trying to develop a custom module for my d6 website that allows users to register and register on my website, just as a regular user will use the existing drupal registration and registration system.

I looked at the fbconnect module (which has not been updated to use the latest version of php sdk [ver 3]), and drupal for facebook , which matches the facebook login with an existing user ID, if the drupal user with the same email address exists - and it's not that what i'm looking for.

What I'm looking for:

  • A user comes to my site. Click on the login using facebook.
  • He is shown a fb popup. User grants permissions.
  • At this point I will register it on the site and register it.
  • Now he has access to all permissions set for the authenticated user to create messages, etc.
  • He goes out. Returns again and enters the system, and this time all the content that he created for the first time is available to him in the same way as an ordinary authenticated user.

I am having problems visualizing the structure of the module. How can i achieve this? I know that I need to use server-side authentication as indicated here .

I am good at creating Drupal modules, just having trouble reviewing the architecture of this. I would really appreciate the big picture if anyone has experience with this. I would be on top of the world if someone has detailed steps to offer.

+4
source share
1 answer

I register users automatically with my Facebook ID without a pass, so they can only log in if Facebook approves them and recognizes them as Facebook users.

I am using the PHP SDK for Facebook. Also remember that you need a signed request, and the user you are trying to register with must accept your APP before attempting to register (in order to get his / her user ID).

You can get a signed request with the registration plugin OR on the Facebook page tab ...

Here is my code, it is not fully tested, but it works, and will probably help you find a way.

// Registro automático en Drupal con datos de Facebook function fbconex_registro() { global $facebook; global $user; $SR = $facebook->getSignedRequest(); if ($SR['registration']) { $datos = $SR['registration']; $usuario_nuevo['status'] = 1; $usuario_nuevo['mail'] = $datos['email']; $usuario_nuevo['name'] = 'fb-' . $facebook->getUser(); // Comprobar que el usuario no existe $usuario_nuevo = user_save(null, $usuario_nuevo); if (!$usuario_nuevo) { $html .= 'Se detectaron problemas. No se pudo registrar.'; }; } else { $html .= 'Para iniciar sesión o registrarse visite <a href="/concursocial/sesion">mi sesión</a><br/>'; if ($user->uid != 0) drupal_goto('user'); } if ($usuario_nuevo) { $user = $usuario_nuevo; drupal_goto('user'); } return $html; } 
0
source

Source: https://habr.com/ru/post/1384988/


All Articles