0

I have a django-based site that has private content and a small number of necessary users. I would like for everyone to use their Google account to authenticate using python-social-auth (PSA). I would therefore like to use the following process to add new users:

  1. The new user visits the site and clicks on a "request access" button.
  2. PSA would create a disabled user. The requesting user would be redirected to a page stating that access will be granted within 24 hours if approved.
  3. The site admin would receive an email message notifying her of the request. If the new user is approved, then his account is enabled and the user is notified. If the request is not approved then the disabled account is deleted.

Once the user is enabled, he will login using the pipeline from this tutorial that only authenticates registered users. That part's easy. The hard part is figuring out how I'm going to register users but not authenticate them.

I tried extending the SOCIAL_AUTH_PIPELINE by adding a custom pipeline function that disables users if they're new. However, the pipeline continues to execute at that time, and it appears that it then tries to authenticate the new, disabled user. I say this because I'm redirected in my app to this URL:

...which for me is a 404. This URL seems to be generated by PSA.

So here are my questions:

  • Is it possible for me to drop out of the SOCIAL_AUTH_PIPELINE and redirect my user to a "please wait for authorization" screen if they're a new user? I don't think that I can use a "partial pipeline" for this because I don't want to pick up the pipeline again later - I just want to "drop out" if this is a new user.
  • If that's not possible, then what's option B? Is it creating a custom pipeline that only handles registration? If so, then how would one do that?
Tom Purl
  • 519
  • 4
  • 20

1 Answers1

0

You can keep your pipeline that flags the user as disabled, but also define this setting SOCIAL_AUTH_INACTIVE_USER_URL = "/wait-for-activation" (point it to the URL that shows the "wait for activation" page).

omab
  • 3,721
  • 19
  • 23