소스 검색

[api] Change JWT field username -> userId

Harshg999 4 년 전
부모
커밋
1f2081bcd7
2개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 1
      desktop/core/src/desktop/auth/api_authentications.py
  2. 2 2
      desktop/core/src/desktop/auth/api_authentications_tests.py

+ 1 - 1
desktop/core/src/desktop/auth/api_authentications.py

@@ -51,7 +51,7 @@ class JwtAuthentication(authentication.BaseAuthentication):
     except Exception as e:
       raise exceptions.AuthenticationFailed(e)
 
-    user = find_or_create_user(payload['username'], is_superuser=False)
+    user = find_or_create_user(payload['userId'], is_superuser=False)
     ensure_has_a_group(user)
     user = rewrite_user(user)
 

+ 2 - 2
desktop/core/src/desktop/auth/api_authentications_tests.py

@@ -51,7 +51,7 @@ class TestJwtAuthentication():
     with patch('desktop.auth.api_authentications.jwt.decode') as jwt_decode:
 
       jwt_decode.return_value = {
-        "username": "test"
+        "userId": "test"
       }
 
       user, token = JwtAuthentication().authenticate(request=self.request)
@@ -65,7 +65,7 @@ class TestJwtAuthentication():
     with patch('desktop.auth.api_authentications.jwt.decode') as jwt_decode:
 
       jwt_decode.return_value = {
-        "username": "test_new_user"
+        "userId": "test_new_user"
       }
 
       assert_false(User.objects.filter(username="test_new_user").exists())