-
Notifications
You must be signed in to change notification settings - Fork 92
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
WordPress user creation may fail after Twitter authentication #799
Comments
@mt8 - Apologies for the long delay here. The work-around you're describing won't always work since Can you tell me the exact error you're seeing? Output from the Auth0 plugin log as well as any relevant PHP error logs would be helpful as well. I'm wondering if this might just be a matter of converting the incoming name or possibly and issue with the character encoding on your database. |
@joshcanhelp Hi,
In what cases does this happen? |
@JoanDelilahPepin Thanks. |
I'm not entirely sure, to be honest. All that data comes from Twitter. Aside from that, though ... can you tell me what the error you're seeing is and when you see it? The plugin error log and your server's PHP error log might also have clues here. Since we can't rely on |
@joshcanhelp Thank you for your reply. Okey. Reproduce and report the error again. |
I got this error, when I tried to twitter auth login.
Here is my twitter account. 「モトハチ」 is the |
So, I misspoke before, I do see the https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/overview/user-object Do you see what |
sorry. I also said wrong.
The current plugin seems to be trying to set |
No worries, just wanted to make sure I had my information correct. So ... what we need to do is:
The first step needs to happen in a Rule. This should do the trick: function twitterScreenNameToCustomClaim(user, context, callback) {
if (user.screen_name) {
console.log("Screen name: " + user.screen_name);
context.idToken['https://example.com/screen-name'] = user.screen_name;
}
return callback(null, user, context);
} The second part needs to happen in custom code in your theme or in a custom plugin. I just tested this out and it works on my end: function example_auth0_create_user_data( array $user_data, $userinfo ) {
$userinfo = (array) $userinfo;
if ($userinfo['screen_name']) {
$user_data['user_login'] = $userinfo['screen_name'];
} elseif ( ! empty( $userinfo['https://example.com/screen-name'] ) ) {
$user_data['user_login'] = $userinfo['https://custom-claim/screen-name'];
}
return $user_data;
}
add_action( 'auth0_create_user_data', 'example_auth0_create_user_data', 10, 2 ); |
Thank you for your reply and for providing a great solution. Ideally, it works only with plugins without these support (Rule / WordPress filter). Perfect for someone like me who understands Rules and WordPress filters, but for those who don't, they'll give up on Twitter connections. I would be grateful if you could consider this. |
I appreciate the feedback here. The identity mapping of the Twitter connection is not likely to change anytime soon as that would break anyone relying on how it works already. The problem here is that We are rolling out a better system for doing custom claims, though, one that does not require a URL-type schema. That should allow folks to map Again, thank you for the feedback and for posting the successful test results! Hopefully this can help others in the future 🙇 |
Description
Creating a WordPress username fails if Twitter profile contains unusable characters for WordPress username.
Reproduction
I use Japanese characters on my Twitter profile. If try to Twitter authentication, WordPress user creation will fail.
This is because the following code sets user_login to username.
https://github.com/auth0/wp-auth0/blob/master/lib/WP_Auth0_Users.php#L78
I am solving this with code like this:
I suggest fixing the plugin as it can happen in other languages as well.
Thanks
Environment
The text was updated successfully, but these errors were encountered: