We’re looking to use a pre registration hook to prevent users creating dupicate accounts ie username-password accounts when they have already created one via a social login.
Currently doing something similar via rules but moving to hooks will enable us to actually prevent the account creation rather than just disabling the duplicate post creation.
Anyway strugging to get it to work possibbly because i can’t see how to get the access token needed for the api. Using rules you use “auth0.accessToken” what is the equivalent when using Hooks?
module.exports = function (user, context, cb) {
var response = {};
response.user = user;
// Add user or app metadata to the newly created user
// response.user.user_metadata = { foo: ‘bar’ };
// response.user.app_metadata = { vip: true, score: 7 };
Before diving into a solution; have you considered the automatic account linking feature? It solves this problem, although it is not exactly the same result.
I’ve looked at that and we’ll want to use it for some situations. However that doesn’t solve the situation where a user creates an account via social login and then a hacker creats a new username - password account with the same email and accesses their account. The other way round is fine and we can use account linking but we need to prevent the username - password account from being created if a social login already exists.