I am trying to verified my user using email. It is all working fine but here I want to open a url when one of my api get called. After register I am sending them an email with link to activate account so link is one of my api which is a function I get the user by id and get save email verified and send a response as verified but rather then sending a response I want to automatically send him to the login page. How can I do it? In my frontend I am using react.
this is the activate function or api
@api_view(['GET'])
def activate_user(request, pk):
user = CustomUser.objects.get(id=pk)
print(user)
user.is_email_verified = True
user.save()
return Response('Email Verified')
Just use redirect
from django.shortcuts import redirect
@api_view(['GET'])
def activate_user(request, pk):
user = CustomUser.objects.get(id=pk)
print(user)
user.is_email_verified = True
user.save()
return redirect('https://yourloginpage.com/')