Authenticate login API with user_login.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alberto-AudrixandCursor committed 2026-09-08 15:52:30 +07:00
1 parent 5a58dba347
commit 4f0abceb20
5 files changed
+49 -21

No files matched your search

+5 -5
View File
@@ -6,14 +6,14 @@ from apps.farms.models import Kandang, Site
class KandangFeedInButtonUrlTests(TestCase):
def setUp(self):
self.owner = User.objects.create_user(user_name="owner", password="secret")
self.owner = User.objects.create_user(user_login="owner", password="secret")
self.admin = User.objects.create_user(
user_name="admin",
user_login="admin",
password="admin123",
status=User.STATUS_DIRECTOR_ADMIN,
)
self.staff = User.objects.create_user(
user_name="staff",
user_login="staff",
password="staff123",
status=User.STATUS_GM,
)
@@ -27,11 +27,11 @@ class KandangFeedInButtonUrlTests(TestCase):
token = client.cookies["csrftoken"].value
return {"HTTP_X_CSRFTOKEN": token}
def _login(self, client: Client, user_name: str, password: str) -> None:
def _login(self, client: Client, user_login: str, password: str) -> None:
client.get("/api/v1/auth/csrf/")
response = client.post(
"/api/v1/auth/login/",
{"user_name": user_name, "password": password},
{"user_login": user_login, "password": password},
content_type="application/json",
**self._csrf_headers(client),
)