An Action that denies registration with a bad username.
Runs in a Pre User Registration Action. Every name is checked with context: "username" and the teen policy; change the policy to suit the audience. Replace the key.
// Auth0 Pre User Registration Action
exports.onExecutePreUserRegistration = async (event, api) => {
const res = await fetch('https://api.unprofane.com/v1/check', {
method: 'POST',
headers: { Authorization: `Bearer ${event.secrets.UNPROFANE_API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ text: event.user.username ?? event.user.nickname ?? '', context: 'username', policy: 'teen' }),
});
const result = await res.json();
if (!result.allowed) api.access.deny('username', 'Pick a different username.');
};Store the key in the Action’s secrets. `api.access.deny` carries a reason the sign-up form shows.
What the response holds, and how to read a reserved name apart from a profane one, is in the API reference. The other recipes are on the username page.