Unfortunately, I don’t believe the user-agent is available for the pre-registration hook. The webhook headers contain this data when a user signs up:
{
"host": "us.webtask.run",
"accept-encoding": "gzip",
"authorization": "Bearer 44827...9e96",
"content-type": "application/json",
"ot-baggage-auth0-request-id": "61749a308fe3ec1d",
"ot-tracer-sampled": "true",
"ot-tracer-spanid": "32a...13f3",
"ot-tracer-traceid": "37c6...b5d9",
"request-timeout": "20000",
"x-amzn-trace-id": "Root=1-60...8e6fe",
"x-real-ip": "3.20.244.231",
"x-wt-runtime": "node12",
"x-forwarded-for": "[IP list]",
"x-forwarded-port": "443,8721",
"x-forwarded-proto": "https,https",
"content-length": "368",
"accept-version": "0.0.0",
"x-wt-token": "eyJhbGciOiJIUzI1NiIsImtpZ...NXoWtc6uxR4eJutcM",
"x-wt-params": "eyJjb2RlX2l...VudCJ9",
"connection": "close"
}
And the context object only contains:
@param {object} context - Auth0 connection and other context info
@param {string} context.renderlanguage - language used by signup flow
@param {string} context.request.ip - ip address
@param {string} context.request.language - 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
You can use a rule’s context object to only run the rule after a user signs up like so:
function (user, context, callback) {
// Only run this rule when user signs up
var count = context.stats && context.stats.loginsCount ? context.stats.loginsCount : 0;
if (count > 1) {
return callback(null, user, context);
}
var userAgent = context.request.userAgent;
// throw an error for a particular browser
if (userAgent.includes('Mozilla')) {
return callback(new UnauthorizedError('Access denied for browser: ' + userAgent));
}
callback(null, user, context);
}
In this example, the user would be created, but they would not be able to access the application upon signing up if they were using a particular browser.