// 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; let loginMessage = []; if (global.window.mm_config.EnableSignUpWithGitLab === 'true') { loginMessage.push( ); } if (global.window.mm_config.EnableSignUpWithGoogle === 'true') { loginMessage.push( ); } const extraParam = Utils.getUrlParameter('extra'); let extraBox = ''; if (extraParam) { if (extraParam === Constants.SIGNIN_CHANGE) { extraBox = (
); } else if (extraParam === Constants.SIGNIN_VERIFIED) { extraBox = (
); } else if (extraParam === Constants.SESSION_EXPIRED) { extraBox = (
); } } let emailSignup; if (global.window.mm_config.EnableSignInWithEmail === 'true') { emailSignup = ( ); } if (loginMessage.length > 0 && emailSignup) { loginMessage = (
{loginMessage}
); } let forgotPassword; if (emailSignup) { forgotPassword = ( ); } let userSignUp = null; if (currentTeam.allow_open_invite) { userSignUp = ( ); } let teamSignUp = null; if (global.window.mm_config.EnableTeamCreation === 'true' && !Utils.isMobileApp()) { teamSignUp = ( ); } let ldapLogin = null; if (global.window.mm_config.EnableLdap === 'true') { ldapLogin = ( ); } let usernameLogin = null; if (global.window.mm_config.EnableSignInWithUsername === 'true') { usernameLogin = ( ); } return (

{teamDisplayName}

{extraBox} {loginMessage} {emailSignup} {usernameLogin} {ldapLogin} {userSignUp} {forgotPassword} {teamSignUp}
); } } Login.defaultProps = { }; Login.propTypes = { params: React.PropTypes.object.isRequired };