I don’t know Drupal so I don’t know from which JWT claim (attribute) it takes the username value from. I think it also depends which Drupal OAuth/OIDC plugin you’re using.
My assumption is that it’s taking it from the name
attribute/claim, while the username you user in the signup is in the username
claim/attribute.
It’s very similar to the question here:
You should use a Rule (as shown in the linked threads, but slightly adjusted) to put the username
value as the user name
.
Untested, but should be like this:
function (user, context, callback) {
if (user.name !== user.username) {
var ManagementClient = require('auth0@2.9.1').ManagementClient;
var management = new ManagementClient({
token: auth0.accessToken,
domain: auth0.domain
});
var params = { id: user.user_id };
var data = { nickname : user.username };
management.users.update(params, data, function (err, users) {
if (err) {
//handle err
}
console.log(user);
callback(null, user, context);
});
}
callback(null, user, context);
}