質問

I am using HWIOAuthBundle with FOSUserBundle with success.

When I go to the /login page it redirects me to the Google Accounts, authorizes and returns back to the register form with filled data (except password fields).

Is it possible to auto register user with ommiting register form ?

In this case we do not need password because of authentication with Google Account.

How should I achieve this scenario ?

役に立ちましたか?

解決

A question is a bit old, but better later than never.

You just need to create a custom provider - if you want to integrate the bundle with FOSUserBundle you need to override the FOSUBUserProvider class.

In HWIOAuthBundle/Security/Core/User directory you may find all providers that are available in the OAuthBundle out of the box.

To create new user while connecting you just need to override loadUserByOAuthUserResponse() method of the FOSUBUserProvider (or EntityUserProvider, etc.) provider class. As you may see, default method throws an exception if the user is not found in database, you just need it to call userManager and create new entry.

This is exactly the same situation as with FOSFacebookBundle intergration (if you did so).

Hopes this answer helps you (especially it may sound a bit chaotic).

Edit:
I've posted a blog post explaining the integration process.

他のヒント

Try this gist

or this tutorial

There's a good walk-through on how to integrate HWIOAuthBundle and FOSUserBundle to achieve the automatic user registration and update here, which might be worth a read:

https://gist.github.com/danvbe/4476697

Yes of course.

You should handle a response from google and authorize user manualy something like:

// authorize 
$token = new OAuthToken(null, $user->getRoles());
$token->setUser($user);
$token->setAuthenticated(true);

// update session
$session = $this->getContainer()->get('session');
$session->set('_security_secured_area', serialize($token));
$session->save();

after user was authorized redirect to the call page by user

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top