// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import * as Utils from 'utils/utils.jsx'; import * as Client from 'utils/client.jsx'; import React from 'react'; import ReactDOM from 'react-dom'; import {FormattedMessage} from 'react-intl'; import {browserHistory} from 'react-router'; export default class EmailToLDAP extends React.Component { constructor(props) { super(props); this.submit = this.submit.bind(this); this.state = {}; } submit(e) { e.preventDefault(); var state = {}; const password = ReactDOM.findDOMNode(this.refs.password).value.trim(); if (!password) { state.error = Utils.localizeMessage('claim.email_to_ldap.pwdError', 'Please enter your password.'); this.setState(state); return; } const ldapId = ReactDOM.findDOMNode(this.refs.ldapid).value.trim(); if (!ldapId) { state.error = Utils.localizeMessage('claim.email_to_ldap.ldapIdError', 'Please enter your LDAP ID.'); this.setState(state); return; } const ldapPassword = ReactDOM.findDOMNode(this.refs.ldappassword).value.trim(); if (!ldapPassword) { state.error = Utils.localizeMessage('claim.email_to_ldap.ldapPasswordError', 'Please enter your LDAP password.'); this.setState(state); return; } state.error = null; this.setState(state); var postData = {}; postData.email_password = password; postData.ldap_id = ldapId; postData.ldap_password = ldapPassword; postData.email = this.props.email; postData.team_name = this.props.teamName; Client.emailToLDAP(postData, (data) => { if (data.follow_link) { browserHistory.push(data.follow_link); } }, (error) => { this.setState({error}); } ); } render() { var error = null; if (this.state.error) { error =
; } var formClass = 'form-group'; if (error) { formClass += ' has-error'; } return (