Esempio n. 1
0
 def _create_user(self, username, password, **extra_fields):
     if not username:
         raise ValueError('The given username must be set')
     username = AbstractBaseUser.normalize_username(username)
     user = self.model(username=username, **extra_fields)
     user.set_password(password)
     user.save()
     return user
Esempio n. 2
0
    def create_user(self, username, password, **kwargs):

        if not username:
            raise ValueError("Account must have username")

        username = AbstractBaseUser.normalize_username(username)
        user = self.model(username=username, **kwargs)
        user.set_password(password)
        user.save()
        return user
Esempio n. 3
0
    def create_user(self, username, email=None, password=None, **kwargs):

        if not username:
            raise ValueError('User must have username')

        username = AbstractBaseUser.normalize_username(username)
        email = self.normalize_email(email)
        user = self.model(username=username, email=email, **kwargs)
        user.set_password(password)
        user.save()
        return user
Esempio n. 4
0
    def create_user(self, username, email, password=None):
        if not username:
            raise ValueError('Username required')
        if not email:
            raise ValueError('Email required')

        user = self.model(
            username=AbstractBaseUser.normalize_username(username),
            email=self.normalize_email(email))
        user.set_password(password)
        user.save()
        return user
Esempio n. 5
0
 def validate_username(self, value):
     user = usr.objects.filter(username=value)
     if user:
         raise serializers.ValidationError("Username is already taken")
     return AbstractBaseUser.normalize_username(value)