Skip to content

Commit

Permalink
Use credentialed requests for password updates (#200)
Browse files Browse the repository at this point in the history
Swap `apiClient.put` for `makeCredentialHTTPRequest` in `auth.changePassword` and `auth.resetPassword`.

This should allow those client methods to work even when the client and the API are not on the same origin eg. when using the staging API.
  • Loading branch information
eatyourgreens authored Feb 22, 2023
1 parent e0dc79d commit 6e8b452
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ const authClient = new Model({
},
};

return apiClient.put('/../users', data, config.jsonHeaders)
const url = config.host + '/users';
return makeCredentialHTTPRequest('PUT', url, data, config.jsonHeaders)
.then(function() {
// Resetting the password changes the underlying cookie session data
// need to sign out and back in to refresh
Expand Down Expand Up @@ -297,7 +298,8 @@ const authClient = new Model({
},
};

return apiClient.put('/../users/password', data, config.jsonHeaders);
const url = config.host + '/users/password';
return makeCredentialHTTPRequest('PUT', url, data, config.jsonHeaders);
}.bind(this));
},

Expand Down

0 comments on commit 6e8b452

Please sign in to comment.