for simplicity and security, remove redirect to HTTP and keep everything on HTTPS
This commit is contained in:
parent
1493d3e5ae
commit
d44027c58e
7 changed files with 23 additions and 99 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
.DS_Store
|
||||
.env
|
||||
.env.production
|
||||
.vscode/
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
|
|
|
@ -28,7 +28,6 @@ export const AUTH_ERROR = 'AUTH_ERROR';
|
|||
export const SETTINGS_UPDATED = 'SETTINGS_UPDATED';
|
||||
|
||||
export const SET_PROJECT_NAME = 'SET_PROJECT_NAME';
|
||||
export const SET_SERVE_SECURE = 'SET_SERVE_SECURE';
|
||||
|
||||
export const PROJECT_SAVE_SUCCESS = 'PROJECT_SAVE_SUCCESS';
|
||||
export const PROJECT_SAVE_FAIL = 'PROJECT_SAVE_FAIL';
|
||||
|
|
|
@ -16,13 +16,6 @@ const __process = (typeof global !== 'undefined' ? global : window).process;
|
|||
const ROOT_URL = __process.env.API_URL;
|
||||
|
||||
export function setProject(project) {
|
||||
const targetProtocol = project.serveSecure === true ?
|
||||
protocols.https :
|
||||
protocols.http;
|
||||
|
||||
// This will not reload if on same protocol
|
||||
redirectToProtocol(targetProtocol);
|
||||
|
||||
return {
|
||||
type: ActionTypes.SET_PROJECT,
|
||||
project,
|
||||
|
@ -265,22 +258,6 @@ export function cloneProject() {
|
|||
};
|
||||
}
|
||||
|
||||
export function setServeSecure(serveSecure, { redirect = true } = {}) {
|
||||
return (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: ActionTypes.SET_SERVE_SECURE,
|
||||
serveSecure
|
||||
});
|
||||
|
||||
if (redirect === true) {
|
||||
dispatch(saveProject(false /* autosave */))
|
||||
.then(() => redirectToProtocol(serveSecure === true ? protocols.https : protocols.http));
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
export function showEditProjectName() {
|
||||
return {
|
||||
type: ActionTypes.SHOW_EDIT_PROJECT_NAME
|
||||
|
|
|
@ -59,7 +59,6 @@ class Preferences extends React.Component {
|
|||
<TabList>
|
||||
<div className="preference__subheadings">
|
||||
<Tab><h4 className="preference__subheading">General Settings</h4></Tab>
|
||||
<Tab><h4 className="preference__subheading">Sketch Settings</h4></Tab>
|
||||
<Tab><h4 className="preference__subheading">Accessibility</h4></Tab>
|
||||
</div>
|
||||
</TabList>
|
||||
|
@ -217,34 +216,6 @@ class Preferences extends React.Component {
|
|||
</div>
|
||||
</div>
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
{/* <div className="preference">
|
||||
<h4 className="preference__title">Add a p5.js or an external library</h4>
|
||||
</div> */}
|
||||
<div className="preference">
|
||||
<h4 className="preference__title">Security Protocol</h4>
|
||||
<div className="preference__serve-secure">
|
||||
<input
|
||||
id="serve-secure"
|
||||
type="checkbox"
|
||||
checked={this.props.serveSecure || false}
|
||||
onChange={(event) => {
|
||||
this.props.setServeSecure(event.target.checked);
|
||||
}}
|
||||
/>
|
||||
<label htmlFor="serve-secure">Serve over HTTPS</label>
|
||||
<span
|
||||
className="serve-secture__tooltip tooltipped tooltipped-n tooltipped-no-delay tooltipped-multiline"
|
||||
aria-label={'Choose HTTPS if you need to \n • access a microphone or webcam \n'
|
||||
+ '• access an API served over HTTPS \n\n'
|
||||
+ 'Choose HTTP if you need to \n'
|
||||
+ '• access an API served over HTTP'}
|
||||
>
|
||||
<InlineSVG src={infoUrl} className="serve-secure__icon" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<div className="preference">
|
||||
<h4 className="preference__title">Lint warning sound</h4>
|
||||
|
@ -349,8 +320,6 @@ Preferences.propTypes = {
|
|||
lintWarning: PropTypes.bool.isRequired,
|
||||
setLintWarning: PropTypes.func.isRequired,
|
||||
theme: PropTypes.string.isRequired,
|
||||
serveSecure: PropTypes.bool.isRequired,
|
||||
setServeSecure: PropTypes.func.isRequired,
|
||||
setTheme: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
|
|
|
@ -277,8 +277,6 @@ class IDEView extends React.Component {
|
|||
setSoundOutput={this.props.setSoundOutput}
|
||||
theme={this.props.preferences.theme}
|
||||
setTheme={this.props.setTheme}
|
||||
serveSecure={this.props.project.serveSecure}
|
||||
setServeSecure={this.props.setServeSecure}
|
||||
/>
|
||||
</Overlay>
|
||||
}
|
||||
|
@ -560,7 +558,6 @@ IDEView.propTypes = {
|
|||
project: PropTypes.shape({
|
||||
id: PropTypes.string,
|
||||
name: PropTypes.string.isRequired,
|
||||
serveSecure: PropTypes.bool,
|
||||
owner: PropTypes.shape({
|
||||
username: PropTypes.string,
|
||||
id: PropTypes.string
|
||||
|
@ -568,7 +565,6 @@ IDEView.propTypes = {
|
|||
updatedAt: PropTypes.string
|
||||
}).isRequired,
|
||||
setProjectName: PropTypes.func.isRequired,
|
||||
setServeSecure: PropTypes.func.isRequired,
|
||||
openPreferences: PropTypes.func.isRequired,
|
||||
editorAccessibility: PropTypes.shape({
|
||||
lintMessages: PropTypes.array.isRequired,
|
||||
|
|
|
@ -7,7 +7,6 @@ const initialState = () => {
|
|||
const generatedName = generatedString.charAt(0).toUpperCase() + generatedString.slice(1);
|
||||
return {
|
||||
name: generatedName,
|
||||
serveSecure: isSecurePage(),
|
||||
updatedAt: ''
|
||||
};
|
||||
};
|
||||
|
@ -17,8 +16,6 @@ const project = (state, action) => {
|
|||
state = initialState(); // eslint-disable-line
|
||||
}
|
||||
switch (action.type) {
|
||||
case ActionTypes.SET_SERVE_SECURE:
|
||||
return Object.assign({}, { ...state }, { serveSecure: action.serveSecure });
|
||||
case ActionTypes.SET_PROJECT_NAME:
|
||||
return Object.assign({}, { ...state }, { name: action.name });
|
||||
case ActionTypes.NEW_PROJECT:
|
||||
|
@ -26,7 +23,6 @@ const project = (state, action) => {
|
|||
id: action.project.id,
|
||||
name: action.project.name,
|
||||
updatedAt: action.project.updatedAt,
|
||||
serveSecure: action.project.serveSecure,
|
||||
owner: action.owner
|
||||
};
|
||||
case ActionTypes.SET_PROJECT:
|
||||
|
@ -34,7 +30,6 @@ const project = (state, action) => {
|
|||
id: action.project.id,
|
||||
name: action.project.name,
|
||||
updatedAt: action.project.updatedAt,
|
||||
serveSecure: action.project.serveSecure,
|
||||
owner: action.owner
|
||||
};
|
||||
case ActionTypes.RESET_PROJECT:
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Route, IndexRoute } from 'react-router';
|
||||
import React from 'react';
|
||||
import forceProtocol, { protocols, findSourceProtocol } from './components/forceProtocol';
|
||||
import App from './modules/App/App';
|
||||
import IDEView from './modules/IDE/pages/IDEView';
|
||||
import FullView from './modules/IDE/pages/FullView';
|
||||
|
@ -24,39 +23,27 @@ const onRouteChange = (store) => {
|
|||
store.dispatch(stopSketch());
|
||||
};
|
||||
|
||||
const routes = (store) => {
|
||||
const sourceProtocol = findSourceProtocol(store.getState());
|
||||
|
||||
// If the flag is false, we stay on HTTP
|
||||
const forceToHttps = forceProtocol({
|
||||
targetProtocol: protocols.https,
|
||||
sourceProtocol,
|
||||
// prints debugging but does not reload page
|
||||
disable: __process.env.FORCE_TO_HTTPS === false,
|
||||
});
|
||||
|
||||
return (
|
||||
const routes = store => (
|
||||
<Route path="/" component={App} onChange={() => { onRouteChange(store); }}>
|
||||
<IndexRoute component={IDEView} onEnter={checkAuth(store)} />
|
||||
<Route path="/login" component={forceToHttps(LoginView)} />
|
||||
<Route path="/signup" component={forceToHttps(SignupView)} />
|
||||
<Route path="/reset-password" component={forceToHttps(ResetPasswordView)} />
|
||||
<Route path="/verify" component={forceToHttps(EmailVerificationView)} />
|
||||
<Route path="/login" component={LoginView} />
|
||||
<Route path="/signup" component={SignupView} />
|
||||
<Route path="/reset-password" component={ResetPasswordView} />
|
||||
<Route path="/verify" component={EmailVerificationView} />
|
||||
<Route
|
||||
path="/reset-password/:reset_password_token"
|
||||
component={forceToHttps(NewPasswordView)}
|
||||
component={NewPasswordView}
|
||||
/>
|
||||
<Route path="/projects/:project_id" component={IDEView} />
|
||||
<Route path="/full/:project_id" component={FullView} />
|
||||
<Route path="/sketches" component={IDEView} />
|
||||
<Route path="/assets" component={IDEView} />
|
||||
<Route path="/account" component={forceToHttps(AccountView)} />
|
||||
<Route path="/account" component={AccountView} />
|
||||
<Route path="/:username/sketches/:project_id" component={IDEView} />
|
||||
<Route path="/:username/sketches" component={IDEView} />
|
||||
<Route path="/about" component={IDEView} />
|
||||
<Route path="/feedback" component={IDEView} />
|
||||
</Route>
|
||||
);
|
||||
};
|
||||
);
|
||||
|
||||
export default routes;
|
||||
|
|
Loading…
Reference in a new issue