Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist user in database #13

Closed
EmmanuelVella opened this issue Jan 21, 2012 · 6 comments
Closed

Persist user in database #13

EmmanuelVella opened this issue Jan 21, 2012 · 6 comments

Comments

@EmmanuelVella
Copy link

I'm using FOSUserBundle. After a successful provider authentication, how can I persist the user in my database ?

@SkaveRat
Copy link

an example for this would be usefull

@jalonsoa
Copy link

Please, would be great !

@SkaveRat
Copy link

after trying around with verious methods, I don't think it's easy to use this with FOSUserBundle.

And as the maintainer doesn't respond about anything here, I'll mark this repo as dead for me. I'll have to live with email auth for now...

@jalonsoa
Copy link

Hi !
finally, I can find a solution that work for me. I declare the fos_user as user provider on security.yml. Then I wrote an AuthenticationProvider (based on AuthenticationProvider from etcpasswdoauthbundle), with authenticate method thats make the trick.

    $data = $token->getResponse()->getJson();
    try {
        $user = $this->userProvider->loadUserByUsername($token->getUsername());
        // compare user properties with oauth data for updates
    } catch (UsernameNotFoundException $e) {
        // Create user with oauth data
    }

At last, configure the "etcpasswd_oauth.authentication.provider.oauth.class" as my AuthenticationProvider class

I hope that this help you !

j

@SkaveRat
Copy link

Sweet, thanks. Helped me a lot. As I'm just beginning with Sf2, where can I override the configuration of the AuthProvider Class without doing it in the OAuthBundle?

@jalonsoa
Copy link

In your bundle. For example:

src/Acme/YourBundle/Security/Core/Authentication/Provider/OAuthProvider.php (copy the OAuthProvider class from etcpasswd and develop from this)

Then in, your services.yml (or xml) src/Acme/YourBundle/Resources/config/services.yml define a parameter:

parameters:
    etcpasswd_oauth.authentication.provider.oauth.class: Acme\YourBundle\Security\Core\Authentication\Provider\OAuthProvider

j

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants