activist-org / activist

An open-source activism platform
https://activist.org
GNU Affero General Public License v3.0
222 stars 184 forks source link

signup API endpoint #736

Closed to-sta closed 5 months ago

to-sta commented 7 months ago

Terms

Description

We need endpoints for accounts related actions. This issues is about the signup / registration endpoint.

The POST and DELETE methods should be used to create and delete an account.

The API endpoints should be created via APIView rather than a ViewSet.

Contribution

I am happy to help someone to work on this or work on this myself.

jaymeklein commented 6 months ago

Hey @to-sta, i would love to help in this issue and this project! You can assign me to this issue if you want to, and if there's no one else with this in hands. If so, could you give me some directions on the already built API? Where should i create this signup (POST, DELETE) endpoint? i couldn't find anything in the CONTRIBUTING.md file about this specific topic.

I already have some experience with APIs (mostly with Flask), but i can learn Django in no time.

Best regards.

andrewtavis commented 6 months ago

Assigning you here now, @jaymeklein 😊 Thanks for the interest in helping out! @to-sta is busy today, but he'll get back to you soon on directions for the API endpoint! Looking forward to working with you further :) :)

jaymeklein commented 6 months ago

Hey @andrewtavis , thanks for assigning me this issue. I'm gonna wait until he is available to make everything here as clear as possible.

Best regards.

to-sta commented 6 months ago

@jaymeklein thanks for taking on this issue 😃.

All account related API's are inside the directory backend/authentication. We use the django restframework to create API's.

You can find the User model here.

We want to use the APIView class for the implementation of the post and delete method. That should look like:

class SignupView(APIView):
    def post(self, request):
         pass

    def delete(self, request, pk):
         pass

I would suggest to create a seperate serializer for the API as well (instead of using UserSerializer):

class SignupSerializer(serializers.ModelSerializer[User])
     ...

Here is the signup form. There you can see that we are expecting a user_name, password and password_confirmed (or password1 and password2 as you see fit).

Btw @andrewtavis shouldn't there be an email as well for the signup form?

Let me know if you have any other question 😄.

andrewtavis commented 6 months ago

For now, yes @to-sta we'll need an email for this. I'll add that in at some point. Eventually we do want to move away from an email signup/verification as the only option, but I guess it should still be the base :)

jaymeklein commented 6 months ago

Just finished setting up the development environment, and I'll be exploring the project backend so i can do it as close as possible from what you guys already built.

Your way to build APIs is kinda different from everything i've done before, so i may struggle a little bit with all that abstraction.

andrewtavis commented 6 months ago

Here are the rules for the password from the frontend, via a discussion with @to-sta:

Screenshot_2024-03-16 21 09 49

andrewtavis commented 5 months ago

Closing this via #769 😊 Appreciate the help here, @jaymeklein! Hope to see you at the next sync :)

@to-sta will write an issue to do the tests (and potentially do it himself).