Files
mattermost/web/react/components/login.jsx

182 lines
5.6 KiB
React
Raw Normal View History

// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
2015-06-14 23:53:32 -08:00
// See License.txt for license information.
2015-12-08 13:38:43 -05:00
import LoginEmail from './login_email.jsx';
import LoginLdap from './login_ldap.jsx';
2015-06-14 23:53:32 -08:00
import * as Utils from '../utils/utils.jsx';
import Constants from '../utils/constants.jsx';
2016-01-21 14:15:44 -06:00
var FormattedMessage = ReactIntl.FormattedMessage;
export default class Login extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
const teamDisplayName = this.props.teamDisplayName;
const teamName = this.props.teamName;
2015-06-14 23:53:32 -08:00
let loginMessage = [];
2015-10-16 09:10:54 -07:00
if (global.window.mm_config.EnableSignUpWithGitLab === 'true') {
2015-08-14 12:35:43 -04:00
loginMessage.push(
<a
className='btn btn-custom-login gitlab'
href={'/' + teamName + '/login/gitlab'}
>
<span className='icon' />
2015-10-27 22:18:52 -07:00
<span>{'with GitLab'}</span>
</a>
);
}
2015-12-08 13:38:43 -05:00
if (global.window.mm_config.EnableSignUpWithGoogle === 'true') {
loginMessage.push(
<a
className='btn btn-custom-login google'
href={'/' + teamName + '/login/google'}
>
<span className='icon' />
<span>{'with Google Apps'}</span>
</a>
);
2015-08-14 12:35:43 -04:00
}
const extraParam = Utils.getUrlParameter('extra');
let extraBox = '';
if (extraParam) {
let msg;
if (extraParam === Constants.SIGNIN_CHANGE) {
msg = ' Sign-in method changed successfully';
} else if (extraParam === Constants.SIGNIN_VERIFIED) {
msg = ' Email Verified';
}
if (msg != null) {
extraBox = (
<div className='alert alert-success'>
<i className='fa fa-check' />
{msg}
</div>
);
}
}
let emailSignup;
2015-10-16 09:10:54 -07:00
if (global.window.mm_config.EnableSignUpWithEmail === 'true') {
emailSignup = (
2015-12-08 13:38:43 -05:00
<LoginEmail
teamName={this.props.teamName}
/>
);
}
if (loginMessage.length > 0 && emailSignup) {
loginMessage = (
<div>
{loginMessage}
<div className='or__container'>
2015-10-27 22:18:52 -07:00
<span>{'or'}</span>
</div>
</div>
);
2015-08-31 14:06:14 -04:00
}
let forgotPassword;
2015-08-31 14:06:14 -04:00
if (emailSignup) {
forgotPassword = (
<div className='form-group'>
2016-01-21 14:15:44 -06:00
<a href={'/' + teamName + '/reset_password'}>
<FormattedMessage
id='login.forgot_password'
defaultMessage='I forgot my password'
/>
</a>
2015-10-27 22:18:52 -07:00
</div>
);
}
let userSignUp = null;
if (this.props.inviteId) {
userSignUp = (
<div>
<span>{`Don't have an account? `}
2015-10-27 22:18:52 -07:00
<a
href={'/signup_user_complete/?id=' + this.props.inviteId}
className='signup-team-login'
>
{'Create one now'}
</a>
</span>
</div>
);
}
let teamSignUp = null;
2016-01-26 19:53:33 -05:00
if (global.window.mm_config.EnableTeamCreation === 'true' && !Utils.isMobileApp()) {
2015-10-27 22:18:52 -07:00
teamSignUp = (
<div className='margin--extra'>
2015-11-17 17:09:55 -06:00
<a
href='/'
className='signup-team-login'
>
{'Create a new team'}
</a>
</div>
);
}
2015-12-08 13:38:43 -05:00
let ldapLogin = null;
if (global.window.mm_config.EnableLdap === 'true') {
ldapLogin = (
<LoginLdap
teamName={this.props.teamName}
/>
);
}
let findTeams = null;
if (!Utils.isMobileApp()) {
findTeams = (
<div className='form-group margin--extra form-group--small'>
<span>
<a href='/find_team'>
<FormattedMessage
id='login.find_teams'
defaultMessage='Find your other teams'
/>
</a></span>
</div>
);
}
return (
<div className='signup-team__container'>
2015-10-27 22:18:52 -07:00
<h5 className='margin--less'>{'Sign in to:'}</h5>
<h2 className='signup-team__name'>{teamDisplayName}</h2>
2015-10-27 22:18:52 -07:00
<h2 className='signup-team__subdomain'>{'on '}{global.window.mm_config.SiteName}</h2>
{extraBox}
2015-08-14 12:35:43 -04:00
{loginMessage}
{emailSignup}
2015-12-08 13:38:43 -05:00
{ldapLogin}
2015-10-27 22:18:52 -07:00
{userSignUp}
{findTeams}
{forgotPassword}
2015-10-27 22:18:52 -07:00
{teamSignUp}
2015-06-14 23:53:32 -08:00
</div>
);
}
}
Login.defaultProps = {
teamName: '',
2015-09-21 17:52:30 -07:00
teamDisplayName: ''
};
Login.propTypes = {
teamName: React.PropTypes.string,
2015-10-27 22:18:52 -07:00
teamDisplayName: React.PropTypes.string,
inviteId: React.PropTypes.string
};