From 12896bd23eeba79884245c1c29fdc568cf21a7fa Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 14 Mar 2016 08:50:46 -0400 Subject: Converting to Webpack. Stage 1. --- webapp/components/claim/email_to_sso.jsx | 154 +++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 webapp/components/claim/email_to_sso.jsx (limited to 'webapp/components/claim/email_to_sso.jsx') diff --git a/webapp/components/claim/email_to_sso.jsx b/webapp/components/claim/email_to_sso.jsx new file mode 100644 index 000000000..d09449247 --- /dev/null +++ b/webapp/components/claim/email_to_sso.jsx @@ -0,0 +1,154 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import ReactDOM from 'react-dom'; +import * as Utils from 'utils/utils.jsx'; +import * as Client from 'utils/client.jsx'; + +import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'react-intl'; + +const holders = defineMessages({ + pwdError: { + id: 'claim.email_to_sso.pwdError', + defaultMessage: 'Please enter your password.' + }, + pwd: { + id: 'claim.email_to_sso.pwd', + defaultMessage: 'Password' + } +}); + +import React from 'react'; + +class EmailToSSO extends React.Component { + constructor(props) { + super(props); + + this.submit = this.submit.bind(this); + + this.state = {}; + } + submit(e) { + e.preventDefault(); + var state = {}; + + var password = ReactDOM.findDOMNode(this.refs.password).value.trim(); + if (!password) { + state.error = this.props.intl.formatMessage(holders.pwdError); + this.setState(state); + return; + } + + state.error = null; + this.setState(state); + + var postData = {}; + postData.password = password; + postData.email = this.props.email; + postData.team_name = this.props.teamName; + postData.service = this.props.type; + + Client.switchToSSO(postData, + (data) => { + if (data.follow_link) { + window.location.href = 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'; + } + + const uiType = Utils.toTitleCase(this.props.type) + ' SSO'; + + return ( +
+

+ +

+
+

+ +

+

+ +

+

+ +

+
+ +
+ {error} + +
+
+ ); + } +} + +EmailToSSO.defaultProps = { +}; +EmailToSSO.propTypes = { + intl: intlShape.isRequired, + type: React.PropTypes.string.isRequired, + email: React.PropTypes.string.isRequired, + teamName: React.PropTypes.string.isRequired, + teamDisplayName: React.PropTypes.string.isRequired +}; + +export default injectIntl(EmailToSSO); -- cgit v1.2.3-1-g7c22