Is it possible to dynamically change allowedConnections depending on user input in Auth0Lock?

Using the auth0Lock, is it possible to dynamically change the allowedConnections depending on user input? I’ve tried using lock.update on ‘signin submit’ but have yet to be successful. Is there something I’m overlooking?

lock.on('signin submit',  ( ) => {
    lock.update((currentLock) => {
          if(currentLock.getIn('field', 'email', 'value']) === 'desired value') {
             return currentLock.updateIn( 'core', 'allowedConnections'], value => [alternativeDbConnection]);
          }
          return currentLock;
     }
})

Based on the information you provided, in particular, the field alternativeDbConnection I’m making a few assumptions:

  • you have multiple database connections;
  • you want to select the database connection to be used based on the provided username/email.

If my assumptions are correct then you should take a look at the connectionResolver option. Have in mind this is still a beta feature and is restricted to database connections.

1 Like

Thanks! That’s exactly what I was looking for :slight_smile:

Thanks! That’s exactly what I was looking for :slight_smile: