Reputation: 15090
I have a Django application which uses python-social-auth for authentication.
I have this in my django settings:
SOCIAL_AUTH_PIPELINE = (
...
'my.app.my.custom.pipeline',
)
How do I stop the whole user creation process in my custom pipeline?
I have tried throwing various exceptions including ValueError
and AuthException
but the created users remain in the database. Doesn't throwing an exception reverse the database transaction?
Upvotes: 2
Views: 401
Reputation: 11
Define a view in one of your Django app and don't forget to register a path for it:
def access_denied(request):
return HttpResponse("<h1>Access denied</h1>")
And then, the function registered in your custom pipeline just needs to return the view :
if not allowed_email(fields["email"]):
return redirect(access_denied)
Upvotes: 1