iMerica / dj-rest-auth

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

[401 error] After installing dj-rest-auth and deleted a user from user table, server keeps returning 401 error for all endpoints #453

Closed sawohnmarshwe closed 1 year ago

sawohnmarshwe commented 1 year ago

I'm trying to use login/connect social accounts using dj-rest-auth. I use postman to test api request. I installed according to dj-rest-auth doc . I worked smoothly until I delete a user from user table.

My testing process steps:

  1. dj-rest-auth/login [user 1 credential] -> get correct result [user 1]
  2. delete [user 1] in DB
  3. dj-rest-auth/login [user 1 credential] -> user not found [401 unauthorize]
  4. dj-rest-auth/login [user 2 credential] -> user not found [401 unauthorize] ( user 2 exist in table)
  5. all other api get 401 error

Do I need to add some setting for this case?

I have no idea How deleted user affected to all other api

Please advise me. Thank you.

Postman request sample:

http://127.0.0.1:8000/api/dj-rest-auth/login/

{ "username":"example@gmail.com", "email": "example@gmail.com", "password": "example" }

mr-engin3er commented 1 year ago

@sawohnmarshwe can you add complete CURL request here? You can copy CURL requests from postmen.

sawohnmarshwe commented 1 year ago

@mr-engin3er Okay I added CURL in my post. Thanks :)

mr-engin3er commented 1 year ago

This is not a curl request. can you check your HTTP headers? Are you sending the Authorization token by mistake in the login API? If possible try to attach a CURL request with the exact response (a screenshot is also fine).

Steps to copy a postman request as CURL :- stack overflow

sawohnmarshwe commented 1 year ago

@mr-engin3er Sorry for late reply

It is solved after I removed (JWT_AUTH_COOKIE = 'auth'). I don't know why that cause error though