Skip to content

Commit

Permalink
#39 fix : add user_pk value in user api
Browse files Browse the repository at this point in the history
  • Loading branch information
0321minji committed Jul 16, 2024
1 parent 301a50b commit bf30405
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions users/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ def user_sign_up(email:str,password:str, dsId:str, name:str,dsName:str):
user.set_password(password)
user.is_active=False
user.save()

data={
"email":user.email,
'dsId':user.dsId,
'name':user.name,
'dsName':user.dsName,
'pk':user.pk,
}

return data

def login(self, email:str, password:str):
selector = UserSelector()
Expand All @@ -43,6 +53,7 @@ def login(self, email:str, password:str):
'refresh':str(token),
'access':str(token.access_token),
'name':user.name,
'pk':user.pk,
}

return data
Expand Down
14 changes: 13 additions & 1 deletion users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class UserSignUpInputSerializer(serializers.Serializer):
dsName=serializers.CharField()
name=serializers.CharField()

class UserSignUpOutputSerializer(serializers.Serializer):
email=serializers.CharField()
pk=serializers.CharField()
dsId=serializers.CharField()
dsName=serializers.CharField()
name=serializers.CharField()

@swagger_auto_schema(
request_body=UserSignUpInputSerializer,
security=[],
Expand All @@ -44,16 +51,20 @@ def post(self,request):
serializers.is_valid(raise_exception=True)
data=serializers.validated_data

UserService.user_sign_up(
signup_data=UserService.user_sign_up(
email=data.get('email'),
password=data.get('password'),
dsId=data.get('dsId'),
name=data.get('name'),
dsName=data.get('dsName'),
)

output_serializer = self.UserSignUpOutputSerializer(data=signup_data)
output_serializer.is_valid(raise_exception=True)

return Response({
'status':'success',
'data':output_serializer.data,
},status=status.HTTP_201_CREATED)

class UserLoginApi(APIView):
Expand All @@ -68,6 +79,7 @@ class UserLoginOutputSerializer(serializers.Serializer):
refresh=serializers.CharField()
access=serializers.CharField()
name=serializers.CharField()
pk=serializers.CharField()

@swagger_auto_schema(
request_body=UserLoginInputSerializer,
Expand Down

0 comments on commit bf30405

Please sign in to comment.