def validate(self, attrs):
user = authenticate(**self.user_credentials(attrs))<EOL>if user:<EOL><INDENT>if user.is_active:<EOL><INDENT>self.instance = user<EOL><DEDENT>else:<EOL><INDENT>raise serializers.ValidationError(_("<STR_LIT>"))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>error = _("<STR_LIT>")<EOL>raise serializers.ValidationError(error)<EOL><DEDENT>return attrs<EOL>
checks if login credentials are correct