summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
Diffstat (limited to 'webapp')
-rw-r--r--webapp/actions/user_actions.jsx22
-rw-r--r--webapp/components/claim/components/ldap_to_email.jsx17
2 files changed, 29 insertions, 10 deletions
diff --git a/webapp/actions/user_actions.jsx b/webapp/actions/user_actions.jsx
new file mode 100644
index 000000000..370bfc302
--- /dev/null
+++ b/webapp/actions/user_actions.jsx
@@ -0,0 +1,22 @@
+// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import Client from 'utils/web_client.jsx';
+
+export function switchFromLdapToEmail(email, password, ldapPassword, onSuccess, onError) {
+ Client.ldapToEmail(
+ email,
+ password,
+ ldapPassword,
+ (data) => {
+ if (data.follow_link) {
+ window.location.href = data.follow_link;
+ }
+
+ if (onSuccess) {
+ onSuccess(data);
+ }
+ },
+ onError
+ );
+}
diff --git a/webapp/components/claim/components/ldap_to_email.jsx b/webapp/components/claim/components/ldap_to_email.jsx
index 043e043d3..fbc8bcebf 100644
--- a/webapp/components/claim/components/ldap_to_email.jsx
+++ b/webapp/components/claim/components/ldap_to_email.jsx
@@ -2,7 +2,8 @@
// See License.txt for license information.
import * as Utils from 'utils/utils.jsx';
-import Client from 'utils/web_client.jsx';
+
+import {switchFromLdapToEmail} from 'actions/user_actions.jsx';
import React from 'react';
import ReactDOM from 'react-dom';
@@ -16,6 +17,7 @@ export default class LDAPToEmail extends React.Component {
this.state = {};
}
+
submit(e) {
e.preventDefault();
var state = {};
@@ -44,20 +46,15 @@ export default class LDAPToEmail extends React.Component {
state.error = null;
this.setState(state);
- Client.ldapToEmail(
+ switchFromLdapToEmail(
this.props.email,
password,
ldapPassword,
- (data) => {
- if (data.follow_link) {
- window.location.href = data.follow_link;
- }
- },
- (error) => {
- this.setState({error});
- }
+ null,
+ (err) => this.setState({error: err.message})
);
}
+
render() {
var error = null;
if (this.state.error) {