How do I disable new logins and redirect to message page?

41 views
Skip to first unread message

Alexander Todorov

unread,
Aug 4, 2014, 8:35:31 AM8/4/14
to django-so...@googlegroups.com
Hi guys,
my site uses only DSA for users to login. New accounts are created upon first login.

I'd like to disable new logins and redirect to a message page but allow existing members to be able to use the service.


Commenting out the following two entries in the pipeline seems to work:

    'social.pipeline.user.create_user',
    'social.pipeline.social_auth.associate_user',


After a new user tries to login an error occurs and they are transfered to the /login-error URL. How do I redirect to a proper message page?


I think I need to mimic social.pipeline.user.create_user function and raise a custom exception then process it with a custom middleware class and return the URL to the message page which tells the user why new logins are not supported. Am I on the right track ? (I'll be able to try it out later today and let you know).


Regards,
Alex



Matías Aguirre

unread,
Aug 4, 2014, 12:06:38 PM8/4/14
to Alexander Todorov, django-social-auth
Hi Alexander,

There's not need to comment those two pipeline functions, you can add a simple
one instead before the create_user pipeline, something like this should do the
trick:

from django.shortcuts import redirect


def disable_signup(user=None, *args, **kwargs):
if user is None:
return redirect('/signup-is-disabled')


As I said, put that before the create_user, that way you disable signup with
a simple pipeline function while allow signins.

Matías

Excerpts from Alexander Todorov's message of 2014-08-04 09:35:30 -0300:
--
Matías Aguirre (matias...@gmail.com)
Reply all
Reply to author
Forward
0 new messages