Reject social login if user's email is not public

28 views Asked by At

In Dj-Rest-Auth, when creating a new user with social login, I want to reject the login/signup attempt if the user's email is not public, for example in github. Currently, if the user signs up without a public email, the account still gets created with an empty email.

class GithubLogin(SocialLoginView):
    adapter_class = GitHubOAuth2Adapter
    callback_url = 
    client_class = OAuth2Client

This is the view, and here are the settings I have so far to try and fix this

ACCOUNT_EMAIL_REQUIRED = True

SOCIALACCOUNT_EMAIL_REQUIRED = True

ACCOUNT_AUTHENTICATION_METHOD = "email"

ACCOUNT_EMAIL_VERIFICATION = "mandatory"

ACCOUNT_LOGOUNT_ON_GET = True

ACCOUNT_USER_MODEL_USERNAME_FIELD = None

I also tried setting the configuration in github provider social accounts settings field in admin panel, but I still cannot achieve the desired behavior.

{ "EMAIL_AUTHENTICATION": true, "SOCIALACCOUNT_EMAIL_REQUIRED": true }

what needs to be changed so that the user cannot signup/login with our system if there's no public email?

0

There are 0 answers