iMerica / dj-rest-auth

Authentication for Django Rest Framework
https://dj-rest-auth.readthedocs.io/en/latest/index.html
MIT License
1.64k stars 306 forks source link

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

Open ThomasEnglish opened 1 year ago

ThomasEnglish commented 1 year ago

When:

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.

kiraware commented 1 year ago

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?

iMerica commented 1 year ago

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

urbsny commented 1 year ago

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.