From f9a3a4b3949dddecae413b97904c895b2cd887bf Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Wed, 30 Mar 2016 12:49:29 -0400 Subject: Add MFA functionality --- webapp/utils/client.jsx | 38 ++++++++++++++++++++++++++++++++++---- webapp/utils/constants.jsx | 3 ++- 2 files changed, 36 insertions(+), 5 deletions(-) (limited to 'webapp/utils') diff --git a/webapp/utils/client.jsx b/webapp/utils/client.jsx index d42767d31..a596d1e14 100644 --- a/webapp/utils/client.jsx +++ b/webapp/utils/client.jsx @@ -337,13 +337,28 @@ export function logout(success, error) { }); } -export function loginByEmail(name, email, password, success, error) { +export function checkMfa(method, team, loginId, success, error) { + $.ajax({ + url: '/api/v1/users/mfa', + dataType: 'json', + contentType: 'application/json', + type: 'POST', + data: JSON.stringify({method, team_name: team, login_id: loginId}), + success, + error: function onError(xhr, status, err) { + var e = handleError('checkMfa', xhr, status, err); + error(e); + } + }); +} + +export function loginByEmail(name, email, password, token, success, error) { $.ajax({ url: '/api/v1/users/login', dataType: 'json', contentType: 'application/json', type: 'POST', - data: JSON.stringify({name, email, password}), + data: JSON.stringify({name, email, password, token}), success: function onSuccess(data, textStatus, xhr) { track('api', 'api_users_login_success', data.team_id, 'email', data.email); sessionStorage.removeItem(data.id + '_last_error'); @@ -381,13 +396,13 @@ export function loginByUsername(name, username, password, success, error) { }); } -export function loginByLdap(teamName, id, password, success, error) { +export function loginByLdap(teamName, id, password, token, success, error) { $.ajax({ url: '/api/v1/users/login_ldap', dataType: 'json', contentType: 'application/json', type: 'POST', - data: JSON.stringify({teamName, id, password}), + data: JSON.stringify({teamName, id, password, token}), success: function onSuccess(data, textStatus, xhr) { track('api', 'api_users_loginLdap_success', data.team_id, 'id', id); sessionStorage.removeItem(data.id + '_last_error'); @@ -1712,3 +1727,18 @@ export function resendVerification(success, error, teamName, email) { } }); } + +export function updateMfa(data, success, error) { + $.ajax({ + url: '/api/v1/users/update_mfa', + dataType: 'json', + contentType: 'application/json', + type: 'POST', + data: JSON.stringify(data), + success, + error: (xhr, status, err) => { + var e = handleError('updateMfa', xhr, status, err); + error(e); + } + }); +} diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index f0e8c260e..421a46860 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -194,8 +194,9 @@ export default { OFFTOPIC_CHANNEL: 'off-topic', GITLAB_SERVICE: 'gitlab', GOOGLE_SERVICE: 'google', - LDAP_SERVICE: 'ldap', EMAIL_SERVICE: 'email', + LDAP_SERVICE: 'ldap', + USERNAME_SERVICE: 'username', SIGNIN_CHANGE: 'signin_change', SIGNIN_VERIFIED: 'verified', SESSION_EXPIRED: 'expired', -- cgit v1.2.3-1-g7c22