JWT Authentication with Djoser

63 views
Skip to first unread message

MISHEL HANNA

unread,
Feb 15, 2024, 11:37:55 AM2/15/24
to Django users
hello
i want to make api for register but i want modify the way of email activation
in djoser to activate email it done by uuid/token but i do not want it to be done like that
i want to activate the email by verification code
do you have any suggestions or any other libraries i can use it

Benjamini Athanas

unread,
Feb 16, 2024, 4:04:39 AM2/16/24
to django...@googlegroups.com
try this # Custom Djoser serializer
from djoser.serializers import UserCreateSerializer

class CustomUserCreateSerializer(UserCreateSerializer):
    def perform_create(self, serializer):
        user = serializer.save()
        # Generate verification code and send email
        verification_code = generate_verification_code()
        send_verification_email(user.email, verification_code)
        # Store verification code in user profile or custom model
        user.profile.verification_code = verification_code
        user.profile.save()

# Custom Djoser view
from djoser.views import UserCreateView

class CustomUserCreateView(UserCreateView):
    serializer_class = CustomUserCreateSerializer

# URLs
from django.urls import path

urlpatterns = [
    path('auth/users/create/', CustomUserCreateView.as_view(), name='user-create'),
    # Other Djoser URLs...
]

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b56f4747-d1dc-4009-aa5f-923530f1860fn%40googlegroups.com.

Eleuthere Aluma

unread,
Feb 16, 2024, 11:52:28 AM2/16/24
to django...@googlegroups.com
Essaye <slug:slug>.. 

--
Reply all
Reply to author
Forward
0 new messages