huychau / drf-registration

Simple user registration package based on Django Rest Framework. DRF Registration - The easy way to generate registration RESTful APIs
https://pypi.org/project/drf-registration/
MIT License
33 stars 11 forks source link

Support API based account activations #14

Open matteius opened 2 years ago

matteius commented 2 years ago

Thanks for publishing this project, I am using it for inspiration for the registration flow that I am building, however I am finding that in most cases I need to copy in the classes and refactor to make it suite my use cases.

For example, I want the activation page to have the same styling as my React app and call the activation API so I've copied over the RegisterView and modified it to call my own custom method of send_verify_email that constructs the activation link as such:

    activate_link = domain + "/account-activation?token={token}&uidb64={uidb64}".format(
        **generate_uid_and_token(user, activation_token))

This ends up being a route in React, which can parse the query parameters from the URL and call the ActivateAccountView. I also copied over ActivateAccountView and modified it to return regular json response. The rationale here is that we want the same look and feel of our react site, otherwise if we were building Django rendered registration flow we would probably just opt for django-registration.

In this case, the API and views come close here, but because we support MFA or OTP using django-otp our registration flows are more complex than the current version of this library supports out of box. That being said it is great to have this scaffolding, I just fear that I won't be getting improvements from your future library updates without going through some vendoring processes to port over what is relevant to my application. Is there ways this could be made more generic, possibly with a corresponding react library that provides some drop in components to pair with the views? Just some thoughts for future improvements.

huychau commented 2 years ago

@matteius Thanks for the great suggestions. I am busing now, can you give me a hand?

matteius commented 2 years ago

Hey @huychau I too am pretty busy at the moment, but seeing as I have implemented some of this already in my side project (which is closed source), I may be able to find time to contribute some of these enhancements back to the project. Additionally @cwg83 may be able to assist with some of this as well.