Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Add API call to get a user by their email address (#4884)
Browse files Browse the repository at this point in the history
* Add API call to get a user by their email address

* update per review
  • Loading branch information
cpanato authored and enahum committed Dec 28, 2016
1 parent b058241 commit 45c7a66
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client/client.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,15 @@ export default class Client {
end(this.handleResponse.bind(this, 'getByUsername', success, error));
}

getByEmail(email, success, error) {
request.
get(`${this.getUsersRoute()}/email/${email}`).
set(this.defaultHeaders).
type('application/json').
accept('application/json').
end(this.handleResponse.bind(this, 'getByEmail', success, error));
}

login(loginId, password, mfaToken, success, error) {
this.doLogin({login_id: loginId, password, token: mfaToken}, success, error);

Expand Down
15 changes: 15 additions & 0 deletions tests/client_user.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ describe('Client.User', function() {
});
});

it('getByEmail', function(done) {
TestHelper.initBasic(() => {
TestHelper.basicClient().getByEmail(
TestHelper.basicUser().email,
function(data) {
assert.equal(data.email, TestHelper.basicUser().email);
done();
},
function(err) {
done(new Error(err.message));
}
);
});
});

it('getInitialLoad', function(done) {
TestHelper.initBasic(() => {
TestHelper.basicClient().getInitialLoad(
Expand Down

0 comments on commit 45c7a66

Please sign in to comment.