Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
feat(client): Pass along reason in signIn
Browse files Browse the repository at this point in the history
`reason` will be used along with `service` on the auth server to decide when to send notification emails.

fixes #150
  • Loading branch information
Shane Tomlinson committed May 20, 2015
1 parent dff42d0 commit b33b1d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions client/FxAccountClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ define([
* If `true`, the request will skip the incorrect case error
* @param {String} [options.service]
* Service being signed into
* @param {String} [options.reason]
* Reason for sign in. Can be one of: `signin`, `password_check`,
* `password_change`, `password_reset`, `account_unlock`.
* @return {Promise} A promise that will be fulfilled with JSON `xhr.responseText` of the request
*/
FxAccountClient.prototype.signIn = function (email, password, options) {
Expand Down Expand Up @@ -170,6 +173,10 @@ define([
data.service = options.service;
}

if (options.reason) {
data.reason = options.reason;
}

return self.request.send(endpoint, 'POST', null, data)
.then(
function(accountData) {
Expand Down
12 changes: 11 additions & 1 deletion tests/lib/signIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,21 @@ define([
var password = "iliketurtles";

return respond(client.signUp(email, password), RequestMocks.signUp)
.then(function (res) {
.then(function () {
return respond(client.signIn(email, password, {service: 'sync'}), RequestMocks.signIn);
});
});

test('#with reason', function () {
var email = "test" + new Date().getTime() + "@restmail.net";
var password = "iliketurtles";

return respond(client.signUp(email, password), RequestMocks.signUp)
.then(function () {
return respond(client.signIn(email, password, {reason: 'password_change'}), RequestMocks.signIn);
});
});

test('#incorrect email case', function () {

return accountHelper.newVerifiedAccount()
Expand Down

0 comments on commit b33b1d5

Please sign in to comment.