Home > Software engineering >  How can I add social signup, Email verification in my existing django user signup system?
How can I add social signup, Email verification in my existing django user signup system?

Time:11-01

So I am using default django authentication where its taking username and a password for signup. And I have 5 users registered right now.

Now I need 2 features in my user model

  • Facebook/gmail login
  • Email verification

The problem is I dont wanna loose my existing users and their records. The tutorials and methods I can find on internet all starts from scratch. Any idea how can I approach this?

in my views.py

from django.shortcuts import render
from django.views import generic
from django.contrib.auth.forms import UserCreationForm
from django.urls import reverse_lazy

class UserRegistrationView(generic.CreateView):
    form_class = UserCreationForm
    template_name = 'registration/registration.html'
    success_url = reverse_lazy('login')

urls.py

from django.urls import path
from .views import UserRegistrationView

urlpatterns = [
    path('register/',UserRegistrationView.as_view(),name='register'),
]

CodePudding user response:

It depends on you if you want to make it simple by going through this 1-django all auth = https://django-allauth.readthedocs.io/en/latest/installation.html or 2.-you can create an rest api and then implement django social auth and social django

if you go go with second option Geekforgeeks can help you also.

you have to follow oauth2 based protocols to successfully login and signup with them. or you own can make your system you can learn better by using the rest api method first then apply logic for your own application

CodePudding user response:

You can use django-allauth library. This library have multiple social authentication and is easy to use library.

Follow these links for help.

https://django-allauth.readthedocs.io/en/latest/installation.html

https://www.digitalocean.com/community/tutorials/how-to-authenticate-django-apps-using-django-allauth

  • Related