Useraccounts: How to prompt a user for a username on social signup?

My app requires user names for each user. These are shown in the profile and also used as part of the user profile URL. I’m using the useraccounts package for login, and already set it up in a way that the username must be set on sign-up.

This works well for a form-based sign-up. But if I add the social login packages (facebook, twitter etc.), there is no standard way of asking the user to provide an additional username.

useraccounts has a postSignUpHook, but this is only called on form-based login, not on social login. There’s another hook, onSubmitHook, which is actually called if a social login takes place. So I could use this one to hook in. But I have no idea how I can a) stop the redirection to the page that should be shown after successful login, and b) get that redirect URL to forward once the user has entered a username. I could also use the standard Meteor Accounts.onLogin() hook, but here I have the same challenge to get the redirection info.

How do you deal with social logins in an app that requires usernames?

Not sure if possible to have a custom field for those accounts-*. If not possible, you may need to create some sort of hack.

Adding a custom field is not the problem, and for the standard form login it’s quite easy to add to the UI as well. The problem is that these OAuth logins use a completely different login mechanism (popup), and I have to hook into that / add an additional dialog after the signup has taken place. But I also have to make sure I know the correct URL for redirection after the user has added a username.

How about having a check in your layout template, that if the user has not set a username, show the username form. When the username is set, the layout will automatically render the actual page instead. No need to redirect.

(using jade)

   if currentUser.username

Could you use the validateNewUser callback to add the username data?