diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-02-03 07:33:43 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-02-03 07:33:43 -0500 |
commit | 4a09adeb391b23c7e850fec96a2e8a731b70d755 (patch) | |
tree | ca9cc2410dc17de823d923c9e0ff74fea16d2a82 /web/react/utils | |
parent | d31ae207389b7402debbcaa40bb691e86023f1ba (diff) | |
parent | b013f02209c7c128a35d1c54f2d4a7d6a9701f72 (diff) | |
download | chat-4a09adeb391b23c7e850fec96a2e8a731b70d755.tar.gz chat-4a09adeb391b23c7e850fec96a2e8a731b70d755.tar.bz2 chat-4a09adeb391b23c7e850fec96a2e8a731b70d755.zip |
Merge pull request #1991 from rgarmsen2295/plt-976
PLT-976 Adds ability to sign in with username
Diffstat (limited to 'web/react/utils')
-rw-r--r-- | web/react/utils/client.jsx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index 09cd4162a..c4b1bc061 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -305,6 +305,28 @@ export function loginByEmail(name, email, password, success, error) { }); } +export function loginByUsername(name, username, password, success, error) { + $.ajax({ + url: '/api/v1/users/login', + dataType: 'json', + contentType: 'application/json', + type: 'POST', + data: JSON.stringify({name, username, password}), + success: function onSuccess(data, textStatus, xhr) { + track('api', 'api_users_login_success', data.team_id, 'username', data.username); + sessionStorage.removeItem(data.id + '_last_error'); + BrowserStore.signalLogin(); + success(data, textStatus, xhr); + }, + error: function onError(xhr, status, err) { + track('api', 'api_users_login_fail', name, 'username', username); + + var e = handleError('loginByUsername', xhr, status, err); + error(e); + } + }); +} + export function loginByLdap(teamName, id, password, success, error) { $.ajax({ url: '/api/v1/users/login_ldap', |