// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import LoginEmail from './login_email.jsx'; import LoginUsername from './login_username.jsx'; import LoginLdap from './login_ldap.jsx'; import * as Utils from '../utils/utils.jsx'; import * as Client from '../utils/client.jsx'; import Constants from '../utils/constants.jsx'; import TeamStore from '../stores/team_store.jsx'; import {FormattedMessage} from 'mm-intl'; import {browserHistory} from 'react-router'; export default class Login extends React.Component { constructor(props) { super(props); this.getStateFromStores = this.getStateFromStores.bind(this); this.onTeamChange = this.onTeamChange.bind(this); this.state = this.getStateFromStores(); } componentDidMount() { TeamStore.addChangeListener(this.onTeamChange); Client.getMeLoggedIn((data) => { if (data && data.logged_in !== 'false') { browserHistory.push('/' + this.props.params.team + '/channels/town-square'); } }); } componentWillUnmount() { TeamStore.removeChangeListener(this.onTeamChange); } getStateFromStores() { return { currentTeam: TeamStore.getByName(this.props.params.team) }; } onTeamChange() { this.setState(this.getStateFromStores()); } render() { const currentTeam = this.state.currentTeam; if (currentTeam == null) { return
; } const teamDisplayName = currentTeam.display_name; const teamName = currentTeam.name; const ldapEnabled = global.window.mm_config.EnableLdap === 'true'; const usernameSigninEnabled = global.window.mm_config.EnableSignInWithUsername === 'true'; let loginMessage = []; if (global.window.mm_config.EnableSignUpWithGitLab === 'true') { loginMessage.push(