diff --git a/geonode/base/api/serializers.py b/geonode/base/api/serializers.py index f7f7dbd0f2b..7e7399fb94b 100644 --- a/geonode/base/api/serializers.py +++ b/geonode/base/api/serializers.py @@ -76,27 +76,6 @@ def user_serializer(): return ser.UserSerializer -class RegistrationSerializer(serializers.ModelSerializer): - password2 = serializers.CharField(style={"input_type": "password"}, write_only=True) - - class Meta: - model = get_user_model() - fields = ['username', 'password', 'password2'] - extra_kwargs = { - 'password': {'write_only': True} - } - - def save(self): - UserModel = get_user_model() - user = UserModel(username=self.validated_data['username']) - password = self.validated_data['password'] - password2 = self.validated_data['password2'] - if password != password2: - raise serializers.ValidationError({'password': 'Passwords must match.'}) - user.set_password(password) - user.save() - return user - class BaseDynamicModelSerializer(DynamicModelSerializer): def to_representation(self, instance): data = super().to_representation(instance) diff --git a/geonode/people/api/serializers.py b/geonode/people/api/serializers.py index 141f14b8e42..fac4d39a4ed 100644 --- a/geonode/people/api/serializers.py +++ b/geonode/people/api/serializers.py @@ -12,6 +12,27 @@ logger = logging.getLogger(__name__) +class RegistrationSerializer(serializers.ModelSerializer): + password2 = serializers.CharField(style={"input_type": "password"}, write_only=True) + + class Meta: + model = get_user_model() + fields = ['username', 'password', 'password2'] + extra_kwargs = { + 'password': {'write_only': True} + } + + def save(self): + UserModel = get_user_model() + user = UserModel(username=self.validated_data['username']) + password = self.validated_data['password'] + password2 = self.validated_data['password2'] + if password != password2: + raise serializers.ValidationError({'password': 'Passwords must match.'}) + user.set_password(password) + user.save() + return user + class UserSerializer(base_serializers.DynamicModelSerializer): link = base_serializers.AutoLinkField(read_only=True)