dj-rest-auth icon indicating copy to clipboard operation
dj-rest-auth copied to clipboard

Change in `dj_rest_auth.registration.views.RegisterView.get_response_data()` behaviour.

Open ThomasEnglish opened this issue 2 years ago • 3 comments

When:

  • TOKEN_SERIALIZER is set
  • SESSION_LOGIN is not set
  • USE_JWT is not set

Prior Behaviour - Version 2.2.8: dj_rest_auth.registration.views.RegisterView.get_response_data() would return TokenSerializer(user.auth_token, context=self.get_serializer_context()).data: Permalink

Current Behaviour - 3.0.0: dj_rest_auth.registration.views.RegisterView.get_response_data() returns None: Permalink


The change in behaviour caught me out, as the response returned by RegisterView is now 204 - No Content, rather than 201 - Created with the data from the TokenSerializer.

I've explicitly set SESSION_LOGIN = False to fix this in our project, but thought I'd raise an issue here as it was unexpected.

ThomasEnglish avatar Feb 13 '23 16:02 ThomasEnglish

Actually this behaviour is caused by inconsistent of some default value settings in dj_rest_auth. After 3.0.0, all settings are now consistent. I notice this changed behaviour, but forgot to add the documentation about this. Thanks for raising this issue. We should add documentation to set SESSION_LOGIN=False explicitly if TokenSerializer used or fix the code maybe?

kiraware avatar Feb 13 '23 23:02 kiraware

Can you move the settings inside of the REST_AUTH dict @ThomasEnglish ?

iMerica avatar Feb 21 '23 01:02 iMerica

In LoginView, Response serializer data is set even if SESSION_LOGIN=True. It may be better to have the same behavior in LoginView and RegisterView. Personally, I would like TokenSerializer data to be set in RegisterView even if SESSION_LOGIN=True. Or, it would be great if it could be set in settings.py without having to create our own View.

urbsny avatar Mar 03 '23 11:03 urbsny