Disable Social Sign Ups

I have tried using the ‘Disable Social Sign Up’ rule as written here but am still able to create a new user and log in via a Google account with this new user. I also noticed that some have said about using the new ‘Actions’ to achieve this, but I have no idea what I need to write. I assume it is the onExecutePreUserRegistration function I want to use and can see that there is some code to prevent registration by location But what would I write to prevent user sign up from a Google account?

Hi @joe7,

Thanks for reaching out to the Auth0 Community!

To better help you, could you please clarify if you would like to disable the Google connection sign-up but allow logins?

Or would you prefer to have the Google Social connection disabled?

I am looking forward to your reply.

Thanks,
Rueben

Hi @rueben.tiow, I am looking to disable the Google connection sign-up but still allow Google logins.
We have users who are already signed up to the app and they use Google to sign in to their account, and we want to continue to allow them access. However, we want to prevent any new sign-ups.

Thanks

Hi @joe7,

Thank you for your response and clarification.

This should be possible with the script shared in this FAQ. I have tested this on my end and got it to work.

I know you mentioned that it did not work for you. Because of that, could you please send me a direct message with your tenant’s name to investigate further?

Thanks,
Rueben

Thanks @rueben.tiow, I’ve sent a direct message

Hi @joe7,

Thank you for your direct message and updates.

I have inspected your tenant and found that your Disable social signups rule did not specify the Client ID on line 2.

The line of code that needs to be changed:

const CLIENTS_ENABLED = ['REPLACE_WITH_YOUR_CLIENT_ID'];

In this situation, I recommend replacing the dummy value with your Client ID for this to work properly.

Could you please give it a try and let me know how this goes for you?

Thanks,
Rueben

Oh dear, I don’t know how I missed that! Yes that is all working thank you.

1 Like

Hi @rueben.tiow, this is working as expected, I was wondering though if it is possible to redirect a user if they try and sign up?

Hi @joe7,

Thank you for your reply.

I’m glad that everything is working as expected now :clap:!

Unfortunately, it is not possible to redirect a user during a Post User Registration flow.

However, there is a way to make this work in a Post-Login flow.

For some context, whenever a user signs up successfully on your application, they immediately proceed with logging in. This would increment their login count from 0 to 1. Knowing this, we can write a script that checks if their login_count equals 1. If so, we can deduce that it is a new user.

For example, with a Rule:

function (user, context, callback) {
  if(context.stats.loginsCount === 1){
    context.redirect = {
      url: "https://example.com/foo"
    }
  }
  callback(null, user, context);
}

(Reference: Redirect Users from Within Rules)

I hope this helps!

Please let me know if you have any additional questions.

Thanks,
Rueben

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.