Reputation: 62
Any idea if it's possible to assign default group to user as result of registration? So far we found only a way to do it only as part of user login process but see no similar way for registration process.
Upvotes: 2
Views: 384
Reputation: 7054
Auth0 doesn't yet support running custom code at registration time.
A workaround, however, could be to detect the first login (usually after sign up) and act upon it:
function (user, context, callback) {
// if it is the first login (hence the `signup`)
if (context.stats.loginsCount === 1 ) {
// initialize app_metadata
user.app_metadata = user.app_metadata || {};
// set a default group
user.app_metadata.groups = ['default'];
// store the app_metadata
auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
.catch(function(err){
callback(err);
});
}
// continue
callback(null, user, context);
}
Upvotes: 2