reformat login.jsx to meet style guide
Этот коммит содержится в:
@@ -4,64 +4,62 @@
|
|||||||
var utils = require('../utils/utils.jsx');
|
var utils = require('../utils/utils.jsx');
|
||||||
var client = require('../utils/client.jsx');
|
var client = require('../utils/client.jsx');
|
||||||
var UserStore = require('../stores/user_store.jsx');
|
var UserStore = require('../stores/user_store.jsx');
|
||||||
var TeamStore = require('../stores/team_store.jsx');
|
|
||||||
var BrowserStore = require('../stores/browser_store.jsx');
|
var BrowserStore = require('../stores/browser_store.jsx');
|
||||||
var Constants = require('../utils/constants.jsx');
|
var Constants = require('../utils/constants.jsx');
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
handleSubmit: function(e) {
|
handleSubmit: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var state = { }
|
var state = {};
|
||||||
|
|
||||||
var name = this.props.teamName
|
var name = this.props.teamName;
|
||||||
if (!name) {
|
if (!name) {
|
||||||
state.server_error = "Bad team name"
|
state.serverError = 'Bad team name';
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var email = this.refs.email.getDOMNode().value.trim();
|
var email = this.refs.email.getDOMNode().value.trim();
|
||||||
if (!email) {
|
if (!email) {
|
||||||
state.server_error = "An email is required"
|
state.serverError = 'An email is required';
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var password = this.refs.password.getDOMNode().value.trim();
|
var password = this.refs.password.getDOMNode().value.trim();
|
||||||
if (!password) {
|
if (!password) {
|
||||||
state.server_error = "A password is required"
|
state.serverError = 'A password is required';
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BrowserStore.isLocalStorageSupported()) {
|
if (!BrowserStore.isLocalStorageSupported()) {
|
||||||
state.server_error = "This service requires local storage to be enabled. Please enable it or exit private browsing.";
|
state.serverError = 'This service requires local storage to be enabled. Please enable it or exit private browsing.';
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.server_error = "";
|
state.serverError = '';
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
|
|
||||||
client.loginByEmail(name, email, password,
|
client.loginByEmail(name, email, password,
|
||||||
function(data) {
|
function loggedIn(data) {
|
||||||
UserStore.setCurrentUser(data);
|
UserStore.setCurrentUser(data);
|
||||||
UserStore.setLastEmail(email);
|
UserStore.setLastEmail(email);
|
||||||
|
|
||||||
var redirect = utils.getUrlParameter("redirect");
|
var redirect = utils.getUrlParameter('redirect');
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
window.location.pathname = decodeURI(redirect);
|
window.location.pathname = decodeURI(redirect);
|
||||||
} else {
|
} else {
|
||||||
window.location.pathname = '/' + name + '/channels/town-square';
|
window.location.pathname = '/' + name + '/channels/town-square';
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}.bind(this),
|
function loginFailed(err) {
|
||||||
function(err) {
|
if (err.message === 'Login failed because email address has not been verified') {
|
||||||
if (err.message == "Login failed because email address has not been verified") {
|
|
||||||
window.location.href = '/verify_email?name=' + encodeURIComponent(name) + '&email=' + encodeURIComponent(email);
|
window.location.href = '/verify_email?name=' + encodeURIComponent(name) + '&email=' + encodeURIComponent(email);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.server_error = err.message;
|
state.serverError = err.message;
|
||||||
this.valid = false;
|
this.valid = false;
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
@@ -71,10 +69,13 @@ module.exports = React.createClass({
|
|||||||
return { };
|
return { };
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
var server_error = this.state.server_error ? <label className="control-label">{this.state.server_error}</label> : null;
|
var serverError;
|
||||||
var priorEmail = UserStore.getLastEmail() !== "undefined" ? UserStore.getLastEmail() : ""
|
if (this.state.serverError) {
|
||||||
|
serverError = <label className='control-label'>{this.state.serverError}</label>;
|
||||||
|
}
|
||||||
|
var priorEmail = UserStore.getLastEmail();
|
||||||
|
|
||||||
var emailParam = utils.getUrlParameter("email");
|
var emailParam = utils.getUrlParameter('email');
|
||||||
if (emailParam) {
|
if (emailParam) {
|
||||||
priorEmail = decodeURIComponent(emailParam);
|
priorEmail = decodeURIComponent(emailParam);
|
||||||
}
|
}
|
||||||
@@ -84,57 +85,62 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
var focusEmail = false;
|
var focusEmail = false;
|
||||||
var focusPassword = false;
|
var focusPassword = false;
|
||||||
if (priorEmail != "") {
|
if (priorEmail !== '') {
|
||||||
focusPassword = true;
|
focusPassword = true;
|
||||||
} else {
|
} else {
|
||||||
focusEmail = true;
|
focusEmail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var auth_services = JSON.parse(this.props.authServices);
|
var authServices = JSON.parse(this.props.authServices);
|
||||||
|
|
||||||
var login_message = [];
|
var loginMessage = [];
|
||||||
if (auth_services.indexOf(Constants.GITLAB_SERVICE) >= 0) {
|
if (authServices.indexOf(Constants.GITLAB_SERVICE) >= 0) {
|
||||||
login_message.push(
|
loginMessage.push(
|
||||||
<div className="form-group form-group--small">
|
<div className='form-group form-group--small'>
|
||||||
<span><a href={"/"+teamName+"/login/gitlab"}>{"Log in with GitLab"}</a></span>
|
<span><a href={'/' + teamName + '/login/gitlab'}>{'Log in with GitLab'}</a></span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (auth_services.indexOf(Constants.GOOGLE_SERVICE) >= 0) {
|
if (authServices.indexOf(Constants.GOOGLE_SERVICE) >= 0) {
|
||||||
login_message.push(
|
loginMessage.push(
|
||||||
<div className="form-group form-group--small">
|
<div className='form-group form-group--small'>
|
||||||
<span><a href={"/"+teamName+"/login/google"}>{"Log in with Google"}</a></span>
|
<span><a href={'/' + teamName + '/login/google'}>{'Log in with Google'}</a></span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errorClass = '';
|
||||||
|
if (serverError) {
|
||||||
|
errorClass = ' has-error';
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="signup-team__container">
|
<div className='signup-team__container'>
|
||||||
<h5 className="margin--less">Sign in to:</h5>
|
<h5 className='margin--less'>Sign in to:</h5>
|
||||||
<h2 className="signup-team__name">{ teamDisplayName }</h2>
|
<h2 className='signup-team__name'>{teamDisplayName}</h2>
|
||||||
<h2 className="signup-team__subdomain">on { config.SiteName }</h2>
|
<h2 className='signup-team__subdomain'>on {config.SiteName}</h2>
|
||||||
<form onSubmit={this.handleSubmit}>
|
<form onSubmit={this.handleSubmit}>
|
||||||
<div className={server_error ? 'form-group has-error' : 'form-group'}>
|
<div className={'form-group' + errorClass}>
|
||||||
{ server_error }
|
{serverError}
|
||||||
</div>
|
</div>
|
||||||
<div className={server_error ? 'form-group has-error' : 'form-group'}>
|
<div className={'form-group' + errorClass}>
|
||||||
<input autoFocus={focusEmail} type="email" className="form-control" name="email" defaultValue={priorEmail} ref="email" placeholder="Email" />
|
<input autoFocus={focusEmail} type='email' className='form-control' name='email' defaultValue={priorEmail} ref='email' placeholder='Email' />
|
||||||
</div>
|
</div>
|
||||||
<div className={server_error ? 'form-group has-error' : 'form-group'}>
|
<div className={'form-group' + errorClass}>
|
||||||
<input autoFocus={focusPassword} type="password" className="form-control" name="password" ref="password" placeholder="Password" />
|
<input autoFocus={focusPassword} type='password' className='form-control' name='password' ref='password' placeholder='Password' />
|
||||||
</div>
|
</div>
|
||||||
<div className="form-group">
|
<div className='form-group'>
|
||||||
<button type="submit" className="btn btn-primary">Sign in</button>
|
<button type='submit' className='btn btn-primary'>Sign in</button>
|
||||||
</div>
|
</div>
|
||||||
{ login_message }
|
{loginMessage}
|
||||||
<div className="form-group margin--extra form-group--small">
|
<div className='form-group margin--extra form-group--small'>
|
||||||
<span><a href="/find_team">{"Find other " + strings.TeamPlural}</a></span>
|
<span><a href='/find_team'>{'Find other ' + strings.TeamPlural}</a></span>
|
||||||
</div>
|
</div>
|
||||||
<div className="form-group">
|
<div className='form-group'>
|
||||||
<a href={"/" + teamName + "/reset_password"}>I forgot my password</a>
|
<a href={'/' + teamName + '/reset_password'}>I forgot my password</a>
|
||||||
</div>
|
</div>
|
||||||
<div className="margin--extra">
|
<div className='margin--extra'>
|
||||||
<span>{"Want to create your own " + strings.Team + "?"} <a href="/" className="signup-team-login">Sign up now</a></span>
|
<span>{'Want to create your own ' + strings.Team + '?'} <a href='/' className='signup-team-login'>Sign up now</a></span>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user