Tell whether the server is a proxy

This commit is contained in:
Yuya Ochiai
2016-04-25 20:41:02 +09:00
parent a55eb6fa0f
commit 507889066a
2 changed files with 16 additions and 3 deletions

View File

@@ -20,14 +20,24 @@ const LoginModal = React.createClass({
passwordNode.value = ''; passwordNode.value = '';
}, },
render: function() { render: function() {
var serverType = '';
if (!this.props.show) {
serverType = '';
} else if (this.props.authInfo.isProxy) {
serverType = 'proxy';
} else {
serverType = 'server';
}
const message = `The ${serverType} ${this.props.authServerURL} requires a username and password.`;
return ( return (
<Modal show={ this.props.show }> <Modal show={ this.props.show }>
<Modal.Header> <Modal.Header>
<Modal.Title>Authentication Required</Modal.Title> <Modal.Title>Authentication Required</Modal.Title>
</Modal.Header> </Modal.Header>
<Modal.Body> <Modal.Body>
<p>The server <p>
{ ' ' + this.props.authServerURL } requires a username and password.</p> { message }
</p>
<Form horizontal onSubmit={ this.handleSubmit }> <Form horizontal onSubmit={ this.handleSubmit }>
<FormGroup> <FormGroup>
<Col componentClass={ ControlLabel } sm={ 2 }>User&nbsp;Name</Col> <Col componentClass={ ControlLabel } sm={ 2 }>User&nbsp;Name</Col>

View File

@@ -194,14 +194,17 @@ var MainPage = React.createClass({
var request = null; var request = null;
var authServerURL = null; var authServerURL = null;
var authInfo = null;
if (this.state.loginQueue.length !== 0) { if (this.state.loginQueue.length !== 0) {
request = this.state.loginQueue[0].request; request = this.state.loginQueue[0].request;
const tmp_url = url.parse(this.state.loginQueue[0].request.url); const tmp_url = url.parse(this.state.loginQueue[0].request.url);
authServerURL = `${tmp_url.protocol}//${tmp_url.host}`; authServerURL = `${tmp_url.protocol}//${tmp_url.host}`;
authInfo = this.state.loginQueue[0].authInfo;
} }
return ( return (
<div> <div>
<LoginModal show={ this.state.loginQueue.length !== 0 } request={ request } authServerURL={ authServerURL } onLogin={ this.handleLogin } onCancel={ this.handleLoginCancel }></LoginModal> <LoginModal show={ this.state.loginQueue.length !== 0 } request={ request } authInfo={ authInfo } authServerURL={ authServerURL } onLogin={ this.handleLogin }
onCancel={ this.handleLoginCancel }></LoginModal>
<Grid fluid> <Grid fluid>
{ tabs_row } { tabs_row }
{ views_row } { views_row }