我在我的网站上使用omab / django-social-auth进行Facebook身份验证。
我想将用户重定向到另一个网站以填写其详细信息。因此,当他们首次使用其Facebook帐户进行身份验证时,我希望将用户设置为非活动状态,然后在他们完成表单后将其保存为活动用户。
我在我的环境下操纵django/contrib/auth/models.py,默认情况下is_active字段为False;但是它们被保存为活动用户,即使我从管理面板添加了一个普通用户也是如此。我是否遗漏了什么?
我想将用户重定向到另一个网站以填写其详细信息。因此,当他们首次使用其Facebook帐户进行身份验证时,我希望将用户设置为非活动状态,然后在他们完成表单后将其保存为活动用户。
我在我的环境下操纵django/contrib/auth/models.py,默认情况下is_active字段为False;但是它们被保存为活动用户,即使我从管理面板添加了一个普通用户也是如此。我是否遗漏了什么?
class User(models.Model):
"""
Users within the Django authentication system are represented by this
model.
Username and password are required. Other fields are optional.
"""
username = models.CharField(_('username'), max_length=30, unique=True,
help_text=_('Required. 30 characters or fewer. Letters, numbers and '
'@/./+/-/_ characters'))
first_name = models.CharField(_('first name'), max_length=30, blank=True)
last_name = models.CharField(_('last name'), max_length=30, blank=True)
email = models.EmailField(_('e-mail address'), blank=True)
password = models.CharField(_('password'), max_length=128)
is_staff = models.BooleanField(_('staff status'), default=False,
help_text=_('Designates whether the user can log into this admin '
'site.'))
is_active = models.BooleanField(_('active'), default=False,
help_text=_('Designates whether this user should be treated as '
'active. Unselect this instead of deleting accounts.'))
is_superuser = models.BooleanField(_('superuser status'), default=False,
help_text=_('Designates that this user has all permissions without '
'explicitly assigning them.'))
last_login = models.DateTimeField(_('last login'), default=timezone.now)
date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
groups = models.ManyToManyField(Group, verbose_name=_('groups'),
blank=True, help_text=_('The groups this user belongs to. A user will '
'get all permissions granted to each of '
'his/her group.'))
user_permissions = models.ManyToManyField(Permission,
verbose_name=_('user permissions'), blank=True,
help_text='Specific permissions for this user.')
objects = UserManager()
def create_user(self, username, email=None, password=None):
"""
Creates and saves a User with the given username, email and password.
"""
now = timezone.now()
if not username:
raise ValueError('The given username must be set')
email = UserManager.normalize_email(email)
user = self.model(username=username, email=email,
is_staff=False, is_active=False, is_superuser=False,
last_login=now, date_joined=now)
user.set_password(password)
user.save(using=self._db)
return user