chore: return user role in user onboard endpoint (#682)

This commit is contained in:
pablohashescobar 2023-04-04 18:07:17 +05:30 committed by GitHub
parent adf366b325
commit 7f7ceec24c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ from plane.db.models import (
WorkspaceMemberInvite, WorkspaceMemberInvite,
Issue, Issue,
IssueActivity, IssueActivity,
WorkspaceMember,
) )
from plane.utils.paginator import BasePaginator from plane.utils.paginator import BasePaginator
@ -72,6 +73,20 @@ class UpdateUserOnBoardedEndpoint(BaseAPIView):
user = User.objects.get(pk=request.user.id) user = User.objects.get(pk=request.user.id)
user.is_onboarded = request.data.get("is_onboarded", False) user.is_onboarded = request.data.get("is_onboarded", False)
user.save() user.save()
if user.last_workspace_id is not None:
user_role = WorkspaceMember.objects.filter(
workspace_id=user.last_workspace_id, member=request.user.id
).first()
return Response(
{
"message": "Updated successfully",
"role": user_role.company_role
if user_role is not None
else None,
},
status=status.HTTP_200_OK,
)
return Response( return Response(
{"message": "Updated successfully"}, status=status.HTTP_200_OK {"message": "Updated successfully"}, status=status.HTTP_200_OK
) )