Skip to content

Problem Creating a User Via API (Setting Token)  #14

@craiglathrop218

Description

@craiglathrop218

My developer found an issue with the API when he was trying to create a new user. Here is his explanation below:

In the Api.prototype.request function in file plugins/request.js, util._extend method is used like this: util._extend(options, this.httpOptions);
but this only makes shallow copy of an object - meaning that this.httpOptions.headers is copied as a reference and later in the method there are lines that put options.headers['Content-Length'] = params.length;

So that last line actually modifies this.httpOptions.headers
and for later call to Api.prototype.request the previous headers are used

I had a login as a POST which were setting the headers and then I had just after that PUT which did not set the headers but because POST set the headers then PUT got the previous request headers

The fix was to replace util._extend with a function that makes deep copies of the objects and not shallow copies
installed deep-extend module that provided a short path to make deep copies of objects
util._extend(options, this.httpOptions); went to deepExtend(options, this.httpOptions);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions