How to overwrite auth0 provider method found in `getInitialProviders()` - @strapi/plugin-users-permissions

That’s a really useful approach to know, thanks for taking the time to post it. I’ve been digging into the docs/source because I needed to customize the providers service to prevent duplicated usernames (when a local account exists say with username “john” and someone comes in from another provider, you can end up with duplicated usernames [known issue]). The username is also case insensitive so username Jon would still be allowed if a username jon was present via the admin panel.

The providers-registry generates/obtains the username for the various providers. The providers service then deals with creating the strapi user if required. I ended up doing it in strapi-server.js in the /extensions/users-permissions/strapi-server.js

module.exports = (plugin) => {
  plugin.services.providers = require('../server/services/providers')
  return plugin;
};

Where providers is the strapi implementation from the node folder copied across and customized as required.

Interestingly I’ve just also noticed strapi will duplicate the email address (create two accounts with the same) if you have a local account already existing say jon@some_provider.com and you then log in with same provider for example, strapi will then still provision another account with the same email address. (but obviously with a differing provider stored - despite advanced settings set to force one account per email address), so that’s something else I’ll need to address for my use case. It’s a problem where people create an account locally (using a provider type address gmail for example) then later log in directly with a provider.