Beispiel #1
0
def create_user(username,
                password,
                is_staff=False,
                is_superuser=False,
                is_active=True,
                password_hashed=False,
                **kwargs):
    user = User()
    user.username = username.lower()
    for key, val in kwargs.items():
        if key and val:
            setattr(user, key, val)
    user.is_staff = is_staff
    user.is_active = is_active
    user.is_superuser = is_superuser
    if not password_hashed:
        user.set_password(password)
    else:
        user.password = password

    # at this stage in the process there is no couch user so it's pointless
    # trying to update it.
    user.DO_NOT_SAVE_COUCH_USER = True
    user.save()
    return user
Beispiel #2
0
 def sync_to_django_user(self):
     try:
         django_user = self.get_django_user()
     except User.DoesNotExist:
         django_user = User(username=self.username)
     for attr in DjangoUserMixin.ATTRS:
         setattr(django_user, attr, getattr(self, attr))
     django_user.DO_NOT_SAVE_COUCH_USER= True
     return django_user
Beispiel #3
0
def create_user(username, password, is_staff=False, is_superuser=False, is_active=True, password_hashed=False, **kwargs):
    user = User()
    user.username = username.lower()
    for key, val in kwargs.items():
        if key and val:
            setattr(user, key, val)
    user.is_staff = is_staff
    user.is_active = is_active
    user.is_superuser = is_superuser
    if not password_hashed:
        user.set_password(password)
    else:
        user.password = password

    # at this stage in the process there is no couch user so it's pointless
    # trying to update it.
    user.DO_NOT_SAVE_COUCH_USER = True
    user.save()
    return user