Skip to content

Commit

Permalink
Merge pull request #27 from spark/feature/password-reset
Browse files Browse the repository at this point in the history
Implement reset password route
  • Loading branch information
idokleinman committed Jun 8, 2016
2 parents 3690464 + dedaa55 commit ae80388
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 30 deletions.
69 changes: 41 additions & 28 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Particle

[src/Particle.js:16-512](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L16-L512 "Source code on GitHub")
[src/Particle.js:16-521](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L16-L521 "Source code on GitHub")

Particle Cloud API wrapper.

Expand All @@ -12,7 +12,7 @@ Most Particle methods take a single unnamed argument object documented as

## constructor

[src/Particle.js:24-27](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L24-L27 "Source code on GitHub")
[src/Particle.js:24-27](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L24-L27 "Source code on GitHub")

Contructor for the Cloud API wrapper.

Expand All @@ -24,7 +24,7 @@ Create a new Particle object and call methods below on it.

## login

[src/Particle.js:36-45](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L36-L45 "Source code on GitHub")
[src/Particle.js:36-45](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L36-L45 "Source code on GitHub")

Login to Particle Cloud using an existing Particle acccount.

Expand All @@ -39,21 +39,34 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## createUser

[src/Particle.js:53-57](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L53-L57 "Source code on GitHub")
[src/Particle.js:53-57](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L53-L57 "Source code on GitHub")

Create a user account for the Particle Cloud

**Parameters**

- `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `$0.username` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Desired username
- `$0.username` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Email of the new user
- `$0.password` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Password

Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)**

## resetPassword

[src/Particle.js:64-66](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L64-L66 "Source code on GitHub")

Send reset password email for a Particle Cloud user account

**Parameters**

- `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `$0.username` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Email of the user

Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)**

## removeAccessToken

[src/Particle.js:66-70](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L66-L70 "Source code on GitHub")
[src/Particle.js:75-79](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L75-L79 "Source code on GitHub")

Revoke an access token

Expand All @@ -68,7 +81,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## listAccessTokens

[src/Particle.js:78-80](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L78-L80 "Source code on GitHub")
[src/Particle.js:87-89](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L87-L89 "Source code on GitHub")

List all valid access tokens for a Particle Cloud account

Expand All @@ -82,7 +95,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## listDevices

[src/Particle.js:87-89](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L87-L89 "Source code on GitHub")
[src/Particle.js:96-98](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L96-L98 "Source code on GitHub")

List devices claimed to the account

Expand All @@ -95,7 +108,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## getDevice

[src/Particle.js:97-99](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L97-L99 "Source code on GitHub")
[src/Particle.js:106-108](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L106-L108 "Source code on GitHub")

Get detailed informationa about a device

Expand All @@ -109,7 +122,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## claimDevice

[src/Particle.js:107-112](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L107-L112 "Source code on GitHub")
[src/Particle.js:116-121](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L116-L121 "Source code on GitHub")

Claim a device to the account. The device must be online and unclaimed.

Expand All @@ -124,7 +137,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## removeDevice

[src/Particle.js:120-122](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L120-L122 "Source code on GitHub")
[src/Particle.js:129-131](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L129-L131 "Source code on GitHub")

Unclaim / Remove a device from your account

Expand All @@ -138,7 +151,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## renameDevice

[src/Particle.js:131-133](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L131-L133 "Source code on GitHub")
[src/Particle.js:140-142](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L140-L142 "Source code on GitHub")

Rename a device

Expand All @@ -153,7 +166,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## getClaimCode

[src/Particle.js:141-143](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L141-L143 "Source code on GitHub")
[src/Particle.js:150-152](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L150-L152 "Source code on GitHub")

Generate a claim code to use in the device claiming process.

Expand All @@ -167,7 +180,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## getVariable

[src/Particle.js:163-165](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L163-L165 "Source code on GitHub")
[src/Particle.js:172-174](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L172-L174 "Source code on GitHub")

Get the value of a device variable

Expand All @@ -182,7 +195,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## signalDevice

[src/Particle.js:174-178](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L174-L178 "Source code on GitHub")
[src/Particle.js:183-187](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L183-L187 "Source code on GitHub")

Instruct the device to turn on/off the LED in a rainbow pattern

Expand All @@ -197,7 +210,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## flashDevice

[src/Particle.js:188-197](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L188-L197 "Source code on GitHub")
[src/Particle.js:197-206](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L197-L206 "Source code on GitHub")

Compile and flash application firmware to a device

Expand All @@ -213,7 +226,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## flashTinker

[src/Particle.js:205-209](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L205-L209 "Source code on GitHub")
[src/Particle.js:214-218](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L214-L218 "Source code on GitHub")

Flash the Tinker application to a device

Expand All @@ -227,7 +240,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## compileCode

[src/Particle.js:219-228](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L219-L228 "Source code on GitHub")
[src/Particle.js:228-237](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L228-L237 "Source code on GitHub")

Compile firmware using the Particle Cloud

Expand All @@ -243,7 +256,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## downloadFirmwareBinary

[src/Particle.js:236-245](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L236-L245 "Source code on GitHub")
[src/Particle.js:245-254](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L245-L254 "Source code on GitHub")

Download a firmware binary

Expand All @@ -257,7 +270,7 @@ Returns **[Request](https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_A

## sendPublicKey

[src/Particle.js:255-263](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L255-L263 "Source code on GitHub")
[src/Particle.js:264-272](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L264-L272 "Source code on GitHub")

Send a new device public key to the Particle Cloud

Expand All @@ -273,7 +286,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## callFunction

[src/Particle.js:273-277](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L273-L277 "Source code on GitHub")
[src/Particle.js:282-286](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L282-L286 "Source code on GitHub")

Call a device function

Expand All @@ -289,7 +302,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## getEventStream

[src/Particle.js:289-313](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L289-L313 "Source code on GitHub")
[src/Particle.js:298-322](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L298-L322 "Source code on GitHub")

Get a stream of events

Expand All @@ -307,7 +320,7 @@ emit 'event' events, as well as the specific named event.

## publishEvent

[src/Particle.js:323-329](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L323-L329 "Source code on GitHub")
[src/Particle.js:332-338](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L332-L338 "Source code on GitHub")

Publish a event to the Particle Cloud

Expand All @@ -323,7 +336,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## createWebhook

[src/Particle.js:348-356](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L348-L356 "Source code on GitHub")
[src/Particle.js:357-365](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L357-L365 "Source code on GitHub")

Create a webhook

Expand All @@ -348,7 +361,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## deleteWebhook

[src/Particle.js:364-366](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L364-L366 "Source code on GitHub")
[src/Particle.js:373-375](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L373-L375 "Source code on GitHub")

Delete a webhook

Expand All @@ -362,7 +375,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## listWebhooks

[src/Particle.js:373-375](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L373-L375 "Source code on GitHub")
[src/Particle.js:382-384](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L382-L384 "Source code on GitHub")

List all webhooks owned by the account

Expand All @@ -375,7 +388,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## getUserInfo

[src/Particle.js:382-384](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L382-L384 "Source code on GitHub")
[src/Particle.js:391-393](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L391-L393 "Source code on GitHub")

Get details about the current user

Expand All @@ -388,7 +401,7 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe

## listBuildTargets

[src/Particle.js:410-416](https://github.com/spark/particle-api-js/blob/82873b6c1e11b6e478648b53b4a9eaaf3afd8055/src/Particle.js#L410-L416 "Source code on GitHub")
[src/Particle.js:419-425](https://github.com/spark/particle-api-js/blob/b71510cee25f8e336cd924ce3c2bfe222ca1edc0/src/Particle.js#L419-L425 "Source code on GitHub")

List valid build targets to be used for compiling

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"istanbul": "^0.4.0",
"minifyify": "^7.3.1",
"mocha": "^2.3.3",
"should": "^7.1.0",
"should": "^9.0.0",
"sinon": "^1.17.0"
},
"dependencies": {
Expand Down
11 changes: 10 additions & 1 deletion src/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Particle {

/**
* Create a user account for the Particle Cloud
* @param {String} $0.username Desired username
* @param {String} $0.username Email of the new user
* @param {String} $0.password Password
* @return {Promise}
*/
Expand All @@ -56,6 +56,15 @@ class Particle {
});
}

/**
* Send reset password email for a Particle Cloud user account
* @param {String} $0.username Email of the user
* @return {Promise}
*/
resetPassword({ username }) {
return this.post('/v1/user/password-reset', { username });
}

/**
* Revoke an access token
* @param {String} $0.username Username of the Particle cloud account that the token belongs to.
Expand Down
7 changes: 7 additions & 0 deletions test/Particle.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ describe('ParticleAPI', () => {
});
});
});
describe('.resetPassword', () => {
it('sends request', () => {
return api.resetPassword(props).then(({ data }) => {
data.username.should.equal(props.username);
});
});
});
describe('.removeAccessToken', () => {
it('sends credentials', () => {
return api.removeAccessToken(props).then(({ auth }) => {
Expand Down

0 comments on commit ae80388

Please sign in to comment.