Unverified Commit 8b60e562 authored by Christopher Speller's avatar Christopher Speller Committed by GitHub
Browse files

Removing unnessisary differentiation between LDAP signup and signin to fix bug...

Removing unnessisary differentiation between LDAP signup and signin to fix bug with signup code. (#1266)
parent 1f0d8cd4
...@@ -40,7 +40,6 @@ import loadPasswordResetSendLink from 'bundle-loader?lazy!components/password_re ...@@ -40,7 +40,6 @@ import loadPasswordResetSendLink from 'bundle-loader?lazy!components/password_re
import loadPasswordResetForm from 'bundle-loader?lazy!components/password_reset_form'; import loadPasswordResetForm from 'bundle-loader?lazy!components/password_reset_form';
import loadSignupController from 'bundle-loader?lazy!components/signup/signup_controller'; import loadSignupController from 'bundle-loader?lazy!components/signup/signup_controller';
import loadSignupEmail from 'bundle-loader?lazy!components/signup/signup_email'; import loadSignupEmail from 'bundle-loader?lazy!components/signup/signup_email';
import loadSignupLdap from 'bundle-loader?lazy!components/signup/signup_ldap';
import loadShouldVerifyEmail from 'bundle-loader?lazy!components/should_verify_email'; import loadShouldVerifyEmail from 'bundle-loader?lazy!components/should_verify_email';
import loadDoVerifyEmail from 'bundle-loader?lazy!components/do_verify_email'; import loadDoVerifyEmail from 'bundle-loader?lazy!components/do_verify_email';
import loadClaimController from 'bundle-loader?lazy!components/claim'; import loadClaimController from 'bundle-loader?lazy!components/claim';
...@@ -62,7 +61,6 @@ const PasswordResetSendLink = makeAsyncComponent(loadPasswordResetSendLink); ...@@ -62,7 +61,6 @@ const PasswordResetSendLink = makeAsyncComponent(loadPasswordResetSendLink);
const PasswordResetForm = makeAsyncComponent(loadPasswordResetForm); const PasswordResetForm = makeAsyncComponent(loadPasswordResetForm);
const SignupController = makeAsyncComponent(loadSignupController); const SignupController = makeAsyncComponent(loadSignupController);
const SignupEmail = makeAsyncComponent(loadSignupEmail); const SignupEmail = makeAsyncComponent(loadSignupEmail);
const SignupLdap = makeAsyncComponent(loadSignupLdap);
const ShouldVerifyEmail = makeAsyncComponent(loadShouldVerifyEmail); const ShouldVerifyEmail = makeAsyncComponent(loadShouldVerifyEmail);
const DoVerifyEmail = makeAsyncComponent(loadDoVerifyEmail); const DoVerifyEmail = makeAsyncComponent(loadDoVerifyEmail);
const ClaimController = makeAsyncComponent(loadClaimController); const ClaimController = makeAsyncComponent(loadClaimController);
...@@ -273,10 +271,6 @@ export default class Root extends React.Component { ...@@ -273,10 +271,6 @@ export default class Root extends React.Component {
path={'/signup_email'} path={'/signup_email'}
component={SignupEmail} component={SignupEmail}
/> />
<HFTRoute
path={'/signup_ldap'}
component={SignupLdap}
/>
<HFTRoute <HFTRoute
path={'/should_verify_email'} path={'/should_verify_email'}
component={ShouldVerifyEmail} component={ShouldVerifyEmail}
......
...@@ -222,7 +222,7 @@ export default class SignupController extends React.Component { ...@@ -222,7 +222,7 @@ export default class SignupController extends React.Component {
<Link <Link
className='btn btn-custom-login btn--full ldap' className='btn btn-custom-login btn--full ldap'
key='ldap' key='ldap'
to={'/signup_ldap' + window.location.search} to={'/login' + this.props.location.search}
> >
<span> <span>
<span className='icon fa fa-folder-open fa--margin-top'/> <span className='icon fa fa-folder-open fa--margin-top'/>
...@@ -278,7 +278,7 @@ export default class SignupController extends React.Component { ...@@ -278,7 +278,7 @@ export default class SignupController extends React.Component {
if (this.props.enableSignUpWithEmail) { if (this.props.enableSignUpWithEmail) {
return browserHistory.push('/signup_email' + window.location.search); return browserHistory.push('/signup_email' + window.location.search);
} else if (this.props.isLicensed && this.props.enableLDAP) { } else if (this.props.isLicensed && this.props.enableLDAP) {
return browserHistory.push('/signup_ldap' + window.location.search); return browserHistory.push('/login' + window.location.search);
} }
} }
......
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {connect} from 'react-redux';
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
import SignupLdap from './signup_ldap.jsx';
function mapStateToProps(state) {
const license = getLicense(state);
const config = getConfig(state);
const isLicensed = license && license.IsLicensed === 'true';
const ldapLoginFieldName = config.LdapLoginFieldName;
const enableLdap = config.EnableLdap === 'true';
const ldap = license.LDAP === 'true';
const siteName = config.SiteName;
const termsOfServiceLink = config.TermsOfServiceLink;
const privacyPolicyLink = config.PrivacyPolicyLink;
const customDescriptionText = config.CustomDescriptionText;
return {
isLicensed,
ldapLoginFieldName,
enableLdap,
ldap,
siteName,
termsOfServiceLink,
privacyPolicyLink,
customDescriptionText,
};
}
export default connect(mapStateToProps)(SignupLdap);
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import PropTypes from 'prop-types';
import React from 'react';
import {FormattedHTMLMessage, FormattedMessage} from 'react-intl';
import {Link} from 'react-router-dom';
import {trackEvent} from 'actions/diagnostics_actions.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import {addUserToTeamFromInvite} from 'actions/team_actions.jsx';
import {loadMe, webLoginByLdap} from 'actions/user_actions.jsx';
import * as Utils from 'utils/utils.jsx';
import {browserHistory} from 'utils/browser_history';
import logoImage from 'images/logo.png';
import BackButton from 'components/common/back_button.jsx';
import FormError from 'components/form_error.jsx';
import SiteNameAndDescription from 'components/common/site_name_and_description';
export default class SignupLdap extends React.Component {
static get propTypes() {
return {
location: PropTypes.object,
isLicensed: PropTypes.bool.isRequired,
ldapLoginFieldName: PropTypes.string,
enableLdap: PropTypes.bool.isRequired,
ldap: PropTypes.bool.isRequired,
siteName: PropTypes.string,
termsOfServiceLink: PropTypes.string,
privacyPolicyLink: PropTypes.string,
customDescriptionText: PropTypes.string.isRequired,
};
}
constructor(props) {
super(props);
this.handleLdapSignup = this.handleLdapSignup.bind(this);
this.handleLdapSignupSuccess = this.handleLdapSignupSuccess.bind(this);
this.handleLdapIdChange = this.handleLdapIdChange.bind(this);
this.handleLdapPasswordChange = this.handleLdapPasswordChange.bind(this);
this.state = ({
ldapError: '',
ldapId: '',
ldapPassword: '',
});
}
componentDidMount() {
trackEvent('signup', 'signup_user_01_welcome');
}
handleLdapIdChange(e) {
this.setState({
ldapId: e.target.value,
});
}
handleLdapPasswordChange(e) {
this.setState({
ldapPassword: e.target.value,
});
}
handleLdapSignup(e) {
e.preventDefault();
this.setState({ldapError: ''});
webLoginByLdap(
this.state.ldapId,
this.state.ldapPassword,
null,
this.handleLdapSignupSuccess,
(err) => {
this.setState({
ldapError: err.message,
});
}
);
}
handleLdapSignupSuccess() {
const params = new URLSearchParams(this.props.location.search);
const token = params.get('t') || '';
const inviteId = params.get('id') || '';
if (inviteId || token) {
addUserToTeamFromInvite(
token,
inviteId,
() => {
this.finishSignup();
},
() => {
// there's not really a good way to deal with this, so just let the user log in like normal
this.finishSignup();
}
);
} else {
this.finishSignup();
}
}
finishSignup() {
loadMe().then(
() => {
const redirectTo = (new URLSearchParams(this.props.location.search)).get('redirect_to');
GlobalActions.loadDefaultLocale();
if (redirectTo) {
browserHistory.push(redirectTo);
} else {
GlobalActions.redirectUserToDefaultTeam();
}
}
);
}
render() {
const {
customDescriptionText,
siteName,
} = this.props;
let ldapIdPlaceholder;
if (this.props.ldapLoginFieldName) {
ldapIdPlaceholder = this.props.ldapLoginFieldName;
} else {
ldapIdPlaceholder = Utils.localizeMessage('login.ldapUsername', 'AD/LDAP Username');
}
let errorClass = '';
if (this.state.ldapError) {
errorClass += ' has-error';
}
let ldapSignup;
if (this.props.enableLdap && this.props.isLicensed && this.props.ldap) {
ldapSignup = (
<div className='inner__content'>
<h5>
<strong>
<FormattedMessage
id='signup.ldap'
defaultMessage='AD/LDAP Credentials'
/>
</strong>
</h5>
<form
onSubmit={this.handleLdapSignup}
>
<div className='signup__email-container'>
<FormError
error={this.state.ldapError}
margin={true}
/>
<div className={'form-group' + errorClass}>
<input
className='form-control'
name='ldapId'
value={this.state.ldapId}
placeholder={ldapIdPlaceholder}
onChange={this.handleLdapIdChange}
spellCheck='false'
autoCapitalize='off'
/>
</div>
<div className={'form-group' + errorClass}>
<input
type='password'
className='form-control'
name='password'
value={this.state.ldapPassword}
placeholder={Utils.localizeMessage('login.password', 'Password')}
onChange={this.handleLdapPasswordChange}
spellCheck='false'
/>
</div>
<div className='form-group'>
<button
type='submit'
className='btn btn-primary'
disabled={!this.state.ldapId || !this.state.ldapPassword}
>
<FormattedMessage
id='login.signIn'
defaultMessage='Sign in'
/>
</button>
</div>
</div>
</form>
</div>
);
} else {
return null;
}
let terms = null;
if (ldapSignup) {
terms = (
<p>
<FormattedHTMLMessage
id='create_team.agreement'
defaultMessage="By proceeding to create your account and use {siteName}, you agree to our <a href='{TermsOfServiceLink}'>Terms of Service</a> and <a href='{PrivacyPolicyLink}'>Privacy Policy</a>. If you do not agree, you cannot use {siteName}."
values={{
siteName: this.props.siteName,
TermsOfServiceLink: this.props.termsOfServiceLink,
PrivacyPolicyLink: this.props.privacyPolicyLink,
}}
/>
</p>
);
}
return (
<div>
<BackButton/>
<div className='col-sm-12'>
<div className='signup-team__container padding--less'>
<img
className='signup-team-logo'
src={logoImage}
/>
<SiteNameAndDescription
customDescriptionText={customDescriptionText}
siteName={siteName}
/>
<h4 className='color--light'>
<FormattedMessage
id='signup_user_completed.lets'
defaultMessage="Let's create your account"
/>
</h4>
<span className='color--light'>
<FormattedMessage
id='signup_user_completed.haveAccount'
defaultMessage='Already have an account?'
/>
{' '}
<Link
to={{
pathname: '/login',
search: this.props.location.search,
}}
>
<FormattedMessage
id='signup_user_completed.signIn'
defaultMessage='Click here to sign in.'
/>
</Link>
</span>
{ldapSignup}
{terms}
</div>
</div>
</div>
);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment