Fixed http port and reset with save
This commit is contained in:
parent
a2dd7c32d5
commit
2c2295c161
|
@ -238,6 +238,7 @@
|
||||||
"encryption_subject": "Subject",
|
"encryption_subject": "Subject",
|
||||||
"encryption_issuer": "Issuer",
|
"encryption_issuer": "Issuer",
|
||||||
"encryption_hostnames": "Hostnames",
|
"encryption_hostnames": "Hostnames",
|
||||||
|
"encryption_reset": "Are you sure you want to reset encryption settings?",
|
||||||
"topline_expiring_certificate": "Your SSL certificate is about to expire. Update <0>Encryption settings</0>.",
|
"topline_expiring_certificate": "Your SSL certificate is about to expire. Update <0>Encryption settings</0>.",
|
||||||
"topline_expired_certificate": "Your SSL certificate is expired. Update <0>Encryption settings</0>.",
|
"topline_expired_certificate": "Your SSL certificate is expired. Update <0>Encryption settings</0>.",
|
||||||
"form_error_port_range": "Enter port value in the range of 80-65535",
|
"form_error_port_range": "Enter port value in the range of 80-65535",
|
||||||
|
|
|
@ -27,9 +27,10 @@ export const setTlsConfigRequest = createAction('SET_TLS_CONFIG_REQUEST');
|
||||||
export const setTlsConfigFailure = createAction('SET_TLS_CONFIG_FAILURE');
|
export const setTlsConfigFailure = createAction('SET_TLS_CONFIG_FAILURE');
|
||||||
export const setTlsConfigSuccess = createAction('SET_TLS_CONFIG_SUCCESS');
|
export const setTlsConfigSuccess = createAction('SET_TLS_CONFIG_SUCCESS');
|
||||||
|
|
||||||
export const setTlsConfig = config => async (dispatch) => {
|
export const setTlsConfig = config => async (dispatch, getState) => {
|
||||||
dispatch(setTlsConfigRequest());
|
dispatch(setTlsConfigRequest());
|
||||||
try {
|
try {
|
||||||
|
const { httpPort } = getState().dashboard;
|
||||||
const values = { ...config };
|
const values = { ...config };
|
||||||
values.certificate_chain = btoa(values.certificate_chain);
|
values.certificate_chain = btoa(values.certificate_chain);
|
||||||
values.private_key = btoa(values.private_key);
|
values.private_key = btoa(values.private_key);
|
||||||
|
@ -41,7 +42,7 @@ export const setTlsConfig = config => async (dispatch) => {
|
||||||
response.private_key = atob(response.private_key);
|
response.private_key = atob(response.private_key);
|
||||||
dispatch(setTlsConfigSuccess(response));
|
dispatch(setTlsConfigSuccess(response));
|
||||||
dispatch(addSuccessToast('encryption_config_saved'));
|
dispatch(addSuccessToast('encryption_config_saved'));
|
||||||
redirectToCurrentProtocol(response);
|
redirectToCurrentProtocol(response, httpPort);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch(addErrorToast({ error }));
|
dispatch(addErrorToast({ error }));
|
||||||
dispatch(setTlsConfigFailure());
|
dispatch(setTlsConfigFailure());
|
||||||
|
|
|
@ -23,7 +23,7 @@ const validate = (values) => {
|
||||||
return errors;
|
return errors;
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearFields = (change) => {
|
const clearFields = (change, setTlsConfig, t) => {
|
||||||
const fields = {
|
const fields = {
|
||||||
private_key: '',
|
private_key: '',
|
||||||
certificate_chain: '',
|
certificate_chain: '',
|
||||||
|
@ -33,7 +33,11 @@ const clearFields = (change) => {
|
||||||
force_https: false,
|
force_https: false,
|
||||||
enabled: false,
|
enabled: false,
|
||||||
};
|
};
|
||||||
Object.keys(fields).forEach(field => change(field, fields[field]));
|
// eslint-disable-next-line no-alert
|
||||||
|
if (window.confirm(t('encryption_reset'))) {
|
||||||
|
Object.keys(fields).forEach(field => change(field, fields[field]));
|
||||||
|
setTlsConfig(fields);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let Form = (props) => {
|
let Form = (props) => {
|
||||||
|
@ -58,6 +62,7 @@ let Form = (props) => {
|
||||||
issuer,
|
issuer,
|
||||||
subject,
|
subject,
|
||||||
warning_validation,
|
warning_validation,
|
||||||
|
setTlsConfig,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -303,7 +308,7 @@ let Form = (props) => {
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-secondary btn-standart"
|
className="btn btn-secondary btn-standart"
|
||||||
disabled={submitting || processingConfig}
|
disabled={submitting || processingConfig}
|
||||||
onClick={() => clearFields(change)}
|
onClick={() => clearFields(change, setTlsConfig, t)}
|
||||||
>
|
>
|
||||||
<Trans>reset_settings</Trans>
|
<Trans>reset_settings</Trans>
|
||||||
</button>
|
</button>
|
||||||
|
@ -335,6 +340,7 @@ Form.propTypes = {
|
||||||
issuer: PropTypes.string,
|
issuer: PropTypes.string,
|
||||||
subject: PropTypes.string,
|
subject: PropTypes.string,
|
||||||
t: PropTypes.func.isRequired,
|
t: PropTypes.func.isRequired,
|
||||||
|
setTlsConfig: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
const selector = formValueSelector('encryptionForm');
|
const selector = formValueSelector('encryptionForm');
|
||||||
|
|
|
@ -8,6 +8,10 @@ import Form from './Form';
|
||||||
import Card from '../../ui/Card';
|
import Card from '../../ui/Card';
|
||||||
|
|
||||||
class Encryption extends Component {
|
class Encryption extends Component {
|
||||||
|
componentDidMount() {
|
||||||
|
this.props.validateTlsConfig(this.props.encryption);
|
||||||
|
}
|
||||||
|
|
||||||
handleFormSubmit = (values) => {
|
handleFormSubmit = (values) => {
|
||||||
this.props.setTlsConfig(values);
|
this.props.setTlsConfig(values);
|
||||||
};
|
};
|
||||||
|
@ -48,6 +52,7 @@ class Encryption extends Component {
|
||||||
}}
|
}}
|
||||||
onSubmit={this.handleFormSubmit}
|
onSubmit={this.handleFormSubmit}
|
||||||
onChange={this.handleFormChange}
|
onChange={this.handleFormChange}
|
||||||
|
setTlsConfig={this.props.setTlsConfig}
|
||||||
{...this.props.encryption}
|
{...this.props.encryption}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
|
@ -171,7 +171,7 @@ export const redirectCheck = (url) => {
|
||||||
}, STOP_TIMEOUT);
|
}, STOP_TIMEOUT);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const redirectToCurrentProtocol = (values) => {
|
export const redirectToCurrentProtocol = (values, httpPort = 80) => {
|
||||||
const {
|
const {
|
||||||
protocol, hostname, hash, port,
|
protocol, hostname, hash, port,
|
||||||
} = window.location;
|
} = window.location;
|
||||||
|
@ -183,6 +183,6 @@ export const redirectToCurrentProtocol = (values) => {
|
||||||
} else if (protocol === 'https:' && enabled && port_https && port_https !== port) {
|
} else if (protocol === 'https:' && enabled && port_https && port_https !== port) {
|
||||||
redirectCheck(`https://${hostname}${httpsPort}/${hash}`);
|
redirectCheck(`https://${hostname}${httpsPort}/${hash}`);
|
||||||
} else if (protocol === 'https:' && (!enabled || !port_https)) {
|
} else if (protocol === 'https:' && (!enabled || !port_https)) {
|
||||||
window.location.replace(`http://${hostname}/${hash}`);
|
window.location.replace(`http://${hostname}:${httpPort}/${hash}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,6 +53,7 @@ const dashboard = handleActions({
|
||||||
upstream_dns: upstreamDns,
|
upstream_dns: upstreamDns,
|
||||||
protection_enabled: protectionEnabled,
|
protection_enabled: protectionEnabled,
|
||||||
language,
|
language,
|
||||||
|
http_port: httpPort,
|
||||||
} = payload;
|
} = payload;
|
||||||
const newState = {
|
const newState = {
|
||||||
...state,
|
...state,
|
||||||
|
@ -65,6 +66,7 @@ const dashboard = handleActions({
|
||||||
upstreamDns: upstreamDns.join('\n'),
|
upstreamDns: upstreamDns.join('\n'),
|
||||||
protectionEnabled,
|
protectionEnabled,
|
||||||
language,
|
language,
|
||||||
|
httpPort,
|
||||||
};
|
};
|
||||||
return newState;
|
return newState;
|
||||||
},
|
},
|
||||||
|
@ -172,6 +174,7 @@ const dashboard = handleActions({
|
||||||
upstreamDns: [],
|
upstreamDns: [],
|
||||||
protectionEnabled: false,
|
protectionEnabled: false,
|
||||||
processingProtection: false,
|
processingProtection: false,
|
||||||
|
httpPort: 80,
|
||||||
});
|
});
|
||||||
|
|
||||||
const queryLogs = handleActions({
|
const queryLogs = handleActions({
|
||||||
|
|
Loading…
Reference in New Issue