2012-09-17 41 views
2

我認爲django userena代表重複發明輪子的用戶註冊信息是不錯的選擇。如何完成django-userena和社會認證的集成

我想以某種方式整合userena和social-auth。但無論我做了什麼,我都無法完成整合。

那麼如何整合這兩種認證系統。

任何想法或幫助將不勝感激......

親切的問候

回答

3

我不能很明白你的想法。但是,考慮到這一點:

1 Userena提供了與用戶連接的抽象模型。使用例如,從源:

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) 

正如你可以看到userena提供了具有該用戶作爲一比一字段的抽象類。

另一方面,django-social-auth知道如何使用不同的社交服務進行身份驗證,並在數據庫中填充表auth_user。其他由django-social-auth修改的表是django-session和social_auth_usersocialauth。這意味着django social auth知道如何進行身份驗證,照顧會話並聚合額外的數據,如令牌。

如果您想要使用userena向用戶添加額外數據,可以在simpler form中完成。

我可以說,使用userena如果:

  • 你需要嫌疑犯照片(圖片)
  • 您需要添加的語言向每個用戶
  • 你需要使用https
  • 您需要確認通過電子郵件帳戶(這有點與使用社交認證相沖突,不是?)
  • 需要一些基本的用戶配置文件管理權限。

更新:如果你想擁有兩個認證,看看這個nice project