Search code examples
django-rest-frameworkdjango-rest-auth

dj_rest_auth restrict user registration to a certaing group


Based on Django REST framework: Check user is in group , I have succesfully restricted my custom views to certain groups.

Yet, I need to restrict dj_rest_auth.views.RegisterView to a certain group.

How can I make it?

I thought of trying to set a wrapper class over RegisterView, and link my wrapper class in urls.py, but what methods should I override?

Thank you SO much!


Solution

  • Well, it seems dj-rest-auth is ready for this need:

    #settings.py
    REST_AUTH_REGISTER_PERMISSION_CLASSES = ("rest_framework.permissions.IsAuthenticated","api.permissions.HasLoginPermission")
    

    Keep in mind there's a bug in dj-rest-auth<1.1.12 that prevents those string to work.