FriendsOfFlarum / passport

The Laravel passport compatible oauth extension for your Flarum forum.
https://discuss.flarum.org/d/5203
MIT License
27 stars 12 forks source link

How can I resuse the User name/nickname of the Oauth2 server. #30

Open guoxiangke opened 1 year ago

guoxiangke commented 1 year ago

Thanks for this package. I successfully make it work. But after Authorize, only the Email was reused, I want the username too. and the avatar too if possiable. thanks.

clarkwinkelmann commented 1 year ago

Those features are not implemented at this time, and I don't think you can add them in without forking the extension.

Those are the lines that would need changing

https://github.com/FriendsOfFlarum/passport/blob/ce398fbba6a9c710eba4aff682d01af1f9284720/src/Controllers/PassportController.php#L102-L104

You could add calls to suggestUsername and provideAvatar, here's how it's done for the GitHub provider for example:

https://github.com/FriendsOfFlarum/oauth/blob/ced387755b58118ae661d8c7882c7d6a48834393/src/Providers/GitHub.php#L63-L67

We have the SendingResponse event but I think it runs too late to impact the user attributes, it's probably designed to change headers and redirect on the HTTP response.