Skip to content

Commit

Permalink
fix: problem with backport
Browse files Browse the repository at this point in the history
  • Loading branch information
jdonlucas committed Aug 15, 2024
1 parent 8ec8c34 commit ba3598e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
21 changes: 0 additions & 21 deletions geonode/base/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions geonode/people/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ba3598e

Please sign in to comment.