sei-ec-remote / project-4-issues

Open an issue to receive help on project 4
0 stars 0 forks source link

Trying to create a user #164

Closed hewinsonj closed 1 year ago

hewinsonj commented 1 year ago

What stack are you using?

(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)

DR

What's the problem you're trying to solve?

Can't create a user.

Post any code you think might be relevant (one fenced block per file)

class SignUp(generics.CreateAPIView):
    # Override the authentication/permissions classes so this endpoint
    # is not authenticated & we don't need any permissions to access it.
    authentication_classes = ()
    permission_classes = ()

    # Serializer classes are required for endpoints that create data
    serializer_class = UserRegisterSerializer

    def post(self, request):
        # Pass the request data to the serializer to validate it
        user = UserRegisterSerializer(data=request.data['credentials'])
        # If that data is in the correct format...
        if user.is_valid():
            # Actually create the user using the UserSerializer (the `create` method defined there)
            created_user = UserSerializer(data=user.data)

            if created_user.is_valid():
                # Save the user and send back a response!
                created_user.save()
                return Response({ 'user': created_user.data }, status=status.HTTP_201_CREATED)
            else:
                return Response(created_user.errors, status=status.HTTP_400_BAD_REQUEST)
        else:
            return Response(user.errors, status=status.HTTP_400_BAD_REQUEST)

If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?

"POST /sign-up/ HTTP/1.1" 500 98188

What is your best guess as to the source of the problem?

It's not genrating an Auth Token

What things have you already tried to solve the problem?

Reading

Paste a link to your repository here

hewinsonj commented 1 year ago

Needed to yeet the creditials off of the UserManager in user_views. Line 23 from boilerplate.