Search code examples
pythondjangodjango-socialauth

How to accomplish integration of django-userena and social auth


I think django userena is good choice for user registration information on behalf of reinventing wheel again and again.

I want to integrate userena with social-auth somehow. But whatever I did, I couldnt accomplish to integrate them.

So how to integrate these two authentication systems.

Any idea or help will be appreciated...

Kind regards


Solution

  • I cant quite understand what you have in mind. However, take this into account:

    1 Userena provides abstract models to be connected with user. using the example from the source:

    from django.db import models
    from django.utils.translation import ugettext_lazy as _
    from django.contrib.auth.models import User
    
    from userena.models import UserenaLanguageBaseProfile
    
    import datetime
    
    class Profile(UserenaLanguageBaseProfile):
        """ Default profile """
        GENDER_CHOICES = (
            (1, _('Male')),
            (2, _('Female')),)
    
        user = models.OneToOneField(User,
                                    unique=True,
                                    verbose_name=_('user'),
                                    related_name='profile') 
    
        gender = models.PositiveSmallIntegerField(_('gender'),
                                                  choices=GENDER_CHOICES,
                                                  blank=True,
                                                  null=True)
        website = models.URLField(_('website'), blank=True, verify_exists=True)
        location =  models.CharField(_('location'), max_length=255, blank=True)
        birth_date = models.DateField(_('birth date'), blank=True, null=True)
        about_me = models.TextField(_('about me'), blank=True)
    

    As you can see userena provides an abstract class that has the user as a one to one field.

    On the other hand, django-social-auth knows how to authenticate with the different social services and populates the table auth_user in the database. Other tables altered by django-social-auth are django-session and social_auth_usersocialauth. This means that django social auth knows how to authenticate, takes care of sessions and aggregates extra data such as tokens.

    If what you have in mind is just to use userena to add extra data to the user this can be done in a simpler form.

    I could say use userena if:

    • You need mugshots (images)
    • You need to add language to each user
    • You need to use https
    • You need to confirm the accounts via email (this kinda collides with using social auth, no?)
    • Need some basic administration of user permissions for profiles.

    update: If you want to have both auth, take a look at this nice project.