From 5ff85df9e92b5ca2c5cd33d3338e3e04190b09cd Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 27 May 2016 11:37:16 -0400 Subject: Display error correctly on ldap to email claim page (#3129) --- webapp/actions/user_actions.jsx | 22 ++++++++++++++++++++++ .../components/claim/components/ldap_to_email.jsx | 17 +++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 webapp/actions/user_actions.jsx (limited to 'webapp') 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) { -- cgit v1.2.3-1-g7c22