add is_superuser, is_staff, and groups to /api/login (#764)

* add is_superuser, is_staff, and groups to /api/login

* fix linting
This commit is contained in:
kralverde 2024-07-17 09:57:45 -04:00 committed by GitHub
parent b97cb9d264
commit 335e6f4b6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -740,7 +740,15 @@ class LoginApiView(ObtainAuthToken):
print(f"returning token for user with id {user.pk}")
return Response({"token": token.key, "user_id": user.pk})
return Response(
{
"token": token.key,
"user_id": user.pk,
"is_superuser": user.is_superuser,
"is_staff": user.is_staff,
"user_groups": [group.name for group in user.groups.all()],
}
)
class SnapshotApiListView(ApiBaseView):