Tivix/django-rest-auth

Unable to login due to rest-auth store password in different format.

sanjaysupanch opened this issue · 1 comments

  • Signup through all-auth form the password store in this format
    "pbkdf2_sha256$180000$cZPa7zIRuSyB$Njb3XmCAyMGvJO/49KBMqYHXYHx+m4xdf27zB+tYPvQ="
  • Signup through rest-auth the password store in this format "!NHJPFX1g7KzLFrqCSLqNuNgeVuO1FWOS5DCxKdPT" thats why unable to login in django.

#=================================serializers.py===============================
`
class RegisterSerializer(serializers.ModelSerializer):
email = serializers.EmailField(required=allauth_settings.EMAIL_REQUIRED)
full_name = serializers.CharField(required=True, write_only=True)
phone_number = serializers.CharField(required=True, write_only=True)
password = serializers.CharField(max_length=255, style={'input_type': 'password'})

class Meta:
    model = CustomUser
    fields = ['id', 'email', 'full_name', 'phone_number', 'password']
    extra_kwargs = {'password': {'write_only':True}}

def validate_email(self, email):
    email = get_adapter().clean_email(email)
    if allauth_settings.UNIQUE_EMAIL:
        if email and email_address_exists(email):
            raise serializers.ValidationError(
                "A user is already registered with this e-mail address.")
    return email

# def validate_password(self, password):
#     return make_password(password)

def get_cleaned_data(self):
    
    return {
        'full_name': self.validated_data.get('full_name', ''),
        'phone_number': self.validated_data.get('phone_number', ''),
        'password': make_password(self.validated_data.get('password', '')),
        'email': self.validated_data.get('email', ''),
        
    }


def save(self, request):
    adapter = get_adapter()
    user = adapter.new_user(request)
    self.cleaned_data = self.get_cleaned_data()
    adapter.save_user(request, user, self)
    setup_user_email(request, user, [])
    return user

`

Please tell me how I store password in correct hashing format

Issue solved