📜 ⬆️ ⬇️

Drupal 6.x and OpenID

CMS Drupal from version 6 has got integrated support for OpenID . But many scold this decision for two reasons:The first problem is still unsolvable - it only comes to my mind to write a special module for this case.
But the solution to the second problem turned out to be quite simple, although it was not described anywhere else.

What is the reason for this strange behavior of Drupal? The fact is that when you try to log in using OpenID, the engine creates a full-fledged user account, taking as information provided by the OpenID provider. But many sites firstly don’t give the login in its pure form, but the full address of the user’s page (for example, login.livejournal.com , instead of just login), in which, of course, there are characters invalid for the Drupal username; and secondly, they do not provide information about the user's e-mail, which is necessary for creating an account in Drupal.

The first part of the problem is solved by a patch from the official site of the project (versions appear on the discussion page ). Not only that now invalid characters are automatically deleted, so the address is also analyzed to determine what the user login is. Thanks to the people from the community.
The second part is also solved easily: you just need to generate a fake address for the user and then Drupal will consider that everything is in order. This is not the best solution because it conflicts with email confirmations, etc. (the address is fake), but it makes life easier for users - no extra steps when trying to login.
To do this, change the part of the line from openid.module:
$ form_state ['values'] ['mail'] = (! empty ($ response ['openid.sreg.email']))? $ response ['openid.sreg.email']: ''; (version after patch application)
or $ form_state ['values'] ['mail'] = (empty ($ response ['openid.sreg.email']))? '': $ response ['openid.sreg.email']; (version before applying the patch)
change to
$ form_state ['values'] ['mail'] = (! empty ($ response ['openid.sreg.email']))? $ response ['openid.sreg.email']: $ form_state ['values'] ['name']. '@ nomail';
')
Now, if the server has not sent the user's e-mail, then the field will be filled with the address of the “user_name @ nomail” type.

I understand and respect the idea of ​​developers that an OpenID login should create a valid Drupal account, but the situations are different - for some, their solution may not be suitable.
Upd: I found a place where I once read the algorithm for treating the second problem (I relied on it) for Drupal 5.x - there is even a ready-made patch. I highly recommend the blog “SolarWind Gate. Notes geek "

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


All Articles