summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2017-01-20 03:02:05 +0100
committerenahum <nahumhbl@gmail.com>2017-01-19 23:02:05 -0300
commit48e1fa8aa0ae3234d826d16eaff39cb373bc7d3d (patch)
treec37ce0309861442288ae36f33064a66e576e58fd
parentd3a285e64d051aa8d5c4c9854597dfbcce107675 (diff)
downloadchat-48e1fa8aa0ae3234d826d16eaff39cb373bc7d3d.tar.gz
chat-48e1fa8aa0ae3234d826d16eaff39cb373bc7d3d.tar.bz2
chat-48e1fa8aa0ae3234d826d16eaff39cb373bc7d3d.zip
Move instances of Client.addUserToTeamFromInvite() in components to an action (#5132)
-rw-r--r--webapp/actions/team_actions.jsx18
-rw-r--r--webapp/components/login/login_controller.jsx15
-rw-r--r--webapp/components/signup/components/signup_ldap.jsx15
-rw-r--r--webapp/components/signup/signup_controller.jsx3
4 files changed, 39 insertions, 12 deletions
diff --git a/webapp/actions/team_actions.jsx b/webapp/actions/team_actions.jsx
index 3a86bada9..aa8628ba3 100644
--- a/webapp/actions/team_actions.jsx
+++ b/webapp/actions/team_actions.jsx
@@ -92,3 +92,21 @@ export function updateTeamMemberRoles(teamId, userId, newRoles, success, error)
}
);
}
+
+export function addUserToTeamFromInvite(data, hash, inviteId, success, error) {
+ Client.addUserToTeamFromInvite(
+ data,
+ hash,
+ inviteId,
+ (team) => {
+ if (success) {
+ success(team);
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
diff --git a/webapp/components/login/login_controller.jsx b/webapp/components/login/login_controller.jsx
index b02d66bbb..3064371c3 100644
--- a/webapp/components/login/login_controller.jsx
+++ b/webapp/components/login/login_controller.jsx
@@ -6,6 +6,7 @@ import ErrorBar from 'components/error_bar.jsx';
import FormError from 'components/form_error.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
+import {addUserToTeamFromInvite} from 'actions/team_actions.jsx';
import BrowserStore from 'stores/browser_store.jsx';
import UserStore from 'stores/user_store.jsx';
@@ -146,12 +147,14 @@ export default class LoginController extends React.Component {
token,
() => {
// check for query params brought over from signup_user_complete
- const query = this.props.location.query;
- if (query.id || query.h) {
- Client.addUserToTeamFromInvite(
- query.d,
- query.h,
- query.id,
+ const hash = this.props.location.query.h;
+ const data = this.props.location.query.d;
+ const inviteId = this.props.location.query.id;
+ if (inviteId || hash) {
+ addUserToTeamFromInvite(
+ data,
+ hash,
+ inviteId,
(team) => {
this.finishSignin(team);
},
diff --git a/webapp/components/signup/components/signup_ldap.jsx b/webapp/components/signup/components/signup_ldap.jsx
index d80b27159..3e8b39a26 100644
--- a/webapp/components/signup/components/signup_ldap.jsx
+++ b/webapp/components/signup/components/signup_ldap.jsx
@@ -5,6 +5,7 @@ import FormError from 'components/form_error.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import {track} from 'actions/analytics_actions.jsx';
+import {addUserToTeamFromInvite} from 'actions/team_actions.jsx';
import * as Utils from 'utils/utils.jsx';
import Client from 'client/web_client.jsx';
@@ -69,11 +70,15 @@ export default class SignupLdap extends React.Component {
}
handleLdapSignupSuccess() {
- if (this.props.location.query.id || this.props.location.query.h) {
- Client.addUserToTeamFromInvite(
- this.props.location.query.d,
- this.props.location.query.h,
- this.props.location.query.id,
+ const hash = this.props.location.query.h;
+ const data = this.props.location.query.d;
+ const inviteId = this.props.location.query.id;
+
+ if (inviteId || hash) {
+ addUserToTeamFromInvite(
+ data,
+ hash,
+ inviteId,
() => {
this.finishSignup();
},
diff --git a/webapp/components/signup/signup_controller.jsx b/webapp/components/signup/signup_controller.jsx
index ee53f6b67..a4cc8f86d 100644
--- a/webapp/components/signup/signup_controller.jsx
+++ b/webapp/components/signup/signup_controller.jsx
@@ -12,6 +12,7 @@ import BrowserStore from 'stores/browser_store.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import Client from 'client/web_client.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
+import {addUserToTeamFromInvite} from 'actions/team_actions.jsx';
import logoImage from 'images/logo.png';
import ErrorBar from 'components/error_bar.jsx';
@@ -68,7 +69,7 @@ export default class SignupController extends React.Component {
const userLoggedIn = UserStore.getCurrentUser() != null;
if ((inviteId || hash) && userLoggedIn) {
- Client.addUserToTeamFromInvite(
+ addUserToTeamFromInvite(
data,
hash,
inviteId,