I am using Hooks for getting a token from Twilio and storing it into user_metadata on Pre User Registration Hook. I also use the standard database for users.
When user is created via Social Connection (in my case it’s Google) the Pre User Registration Hook is not getting triggered. And I get it, I saw comments on the forum that hooks are not supported for Social Connections due to the database limitation. However, here is my point:
When I register a new via Google + standard database, and I go to the admin panel->users I perfectly see that the standard database has an entity there for a user that was created via social connection. And on top of this I can manually modify app_metadata and user_metadata right on the web and save it. That means that Auth0 is still able to create a separate user object in their standard database that has the same functionality as users created via email.
I don’t quite understand why hooks are not enabled with Social Connections.
Also, wanted to ask if somebody know a workaround via Rules and how to use them properly with my hook example (every time a new user registers I pull a create a sub account in twilio and get twill token +metadata and put it into user_metadata)
Hooks code
/**
@param {object} user - The user being created
@param {string} user.tenant - Auth0 tenant name
@param {string} user.username - user name
@param {string} user.password - user’s password
@param {string} user.email - email
@param {boolean} user.emailVerified - is e-mail verified?
@param {string} user.phoneNumber - phone number
@param {boolean} user.phoneNumberVerified - is phone number verified?
@param {object} context - Auth0 connection and other context info
@param {string} context.requestLanguage - language of the client agent
@param {object} context.connection - information about the Auth0 connection
@param {object} context.connection.id - connection id
@param {object} context.connection.name - connection name
@param {object} context.connection.tenant - connection tenant
@param {object} context.webtask - webtask context
@param {function} cb - function (error, response)
*/
module.exports = function (user, context, cb) {
// Perform any asynchronous actions, e.g. send notification to Slack.
var responseObject = {};
responseObject.user = user;
const axios = require(“axios”);
const url = ‘https://api.twilio.com/2010-04-01/Accounts.json’;
const headers = {
‘Content-Type’: ‘application/x-www-form-urlencoded’,
}
const auth = {
username: ‘',
password: '*’,
}
const data = { FriendlyName: user.email }
axios.post(url, data, { headers, auth })
.then(function (response) {
console.log("response.data: “, response);
// Add user or app metadata to the newly created user
responseObject.user.user_metadata = response.data;
cb(null, responseObject);
})
.catch(function (error) {
console.log(error, " errorerror”);
cb(error, null);
});
};
Thank you for you help and if Auth0 guys read this, please respond with quick explanation why by design I can manually modify user_metadata through admin panel for social login users, but hooks don’t work for Social Connections? And When do you expect to enable it?