Procházet zdrojové kódy

[api] Change JWT field username -> userId

Harshg999 před 4 roky
rodič
revize
1f2081bcd7

+ 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())