Today, the only option available to allow account to be created when 3rd party authentication succeed is to set the user_register setting to 1.
The side effect is that local account can also be freely created.
There is possible workaround with custom code by altering 'connector_actions' and providing a custom '_connector_create_account' derivative but it is a fragile way IMHO as it as to be kept in sync with connector evolution.
This issue is about discussing how we could provide a way to allow accounts to be created upon a connector authentication success while preventing free local account creation.

Comments

garphy’s picture

This is a draft implementation that :
1. Adds an additional option in users settings (admin/config/people/accounts) ;
2. Alter _connector_create_account to bypass user_register settings if the previous option is checked.

frans’s picture

What do you mean with:

but it is a fragile way IMHO as it as to be kept in sync with connector evolution

Connector evolution?

Just alter the default action and you are done? I don't see what that has to do with changes on the connector.

Topcheese’s picture

From what I'm understanding there should be an option in the account settings to switch the default behavior of automatically creating an account and logging in. see here Login/signup to Commons site with Google/Facebook account
and here Improved anonymous user permissions We can alter it, but it would be nice to have it come with that option. I"m pretty sure this a bug, because out of the box you can't really use it without having to code--which might introduce new bugs.

That's if you're looking for suggestions. You've almost made the process too easy, so I"m keeping with that. :)

garphy’s picture

Well. To sum up, there's IHMO to main use cases for connector :
* Provide an additional way of logging-in on a website that allow 'local' account creation ;
* Use external authentication as the unique way of logging-in (corporate use).

The first use case works great because account creation permission would be sufficiently liberal to allow the authentication+account creation workflow.

The second cannot be achieved if we don't provide additional code + callback definition alteration. Moreover, the hook_connector_action_alter() doesn't work on a per-connector basis which is rather a limitation IMHO.

Maybe a solution would be extending connector's API by providing more hooks (pre/post & alter) or allow serveral callback to be executed one after another, like Form API allows for 'validate' and 'submit' callbacks.

By the way, for now, as the field synchronization is not really ready*, there's already custom code needed so I'll live with a custom account creation callback for that project.

*mainly for "automated" field synchronization (without prompting user for a form) : it should be part of another issue but it would be far easier to perform field synchronization on top of Field API instead of Form API IMHO.

My 0.02€.

mustanggb’s picture

Issue summary: View changes
Status: Active » Reviewed & tested by the community

Yes please.

Patch works exactly as described, very useful.