I want to add a property called “blockedUser” when the user do the first login and the amount of active users is above 500. This is my action code.
The user is already denied, but if he login again it will be 2 logins in the count and the action will fail.
exports.onExecutePostLogin = async (event, api) => {
const ManagementClient = require(‘auth0’).ManagementClient;
const management = new ManagementClient({
MYCONFIGS…
});
const activeUsers = await management.getActiveUsersCount();
const params = {
search_engine: ‘v3’,
q: email:"${event.user.email}"
};
try {
const users = await management.getUsers(params);
if (activeUsers > 500 && users.length == 1 && event.stats.logins_count == 1) {
// management.users.delete({ id: event.user.user_id })
// i want to add the custom property here
api.access.deny(‘many-users’, ‘We already have our max user capacity’);
}
} catch (e) {
console.log(e)
}
};