p5.js-web-editor/client/modules/IDE/reducers/project.js
Andrew Nicolaou dc801ccf7f Force HTTPS redirection for log in and sign up (#319)
* Higher-order component to force some routes to HTTPS

* Force all user-management routes to HTTPS

* Redirect to sourceProtocol as route unmounts.

By default, no redirection occurs if sourceProtocol is not explicitly
defined.

* Sets serveSecure flag on new projects and usea after forcing protocol

The flag is set to `false` on all projects and as the UI has no way to
change this, it always redirects to HTTP after a signup/login action.

* Move HoC to be with other top-level components

* Server should respond to account page request

* Serves AccountView over HTTPS

* Turns HTTPS redirection off in development by default

Will log to the browser console any redirection that would
have happened. Added a line in the README about how to
enable this for testing in development.
2017-03-30 12:36:26 -04:00

47 lines
1.4 KiB
JavaScript

import generate from 'project-name-generator';
import * as ActionTypes from '../../../constants';
const initialState = () => {
const generatedString = generate({ words: 2 }).spaced;
const generatedName = generatedString.charAt(0).toUpperCase() + generatedString.slice(1);
return {
name: generatedName,
serveSecure: false,
};
};
const project = (state, action) => {
if (state === undefined) {
state = initialState(); // eslint-disable-line
}
switch (action.type) {
case ActionTypes.SET_PROJECT_NAME:
return Object.assign({}, { ...state }, { name: action.name });
case ActionTypes.NEW_PROJECT:
return {
id: action.project.id,
name: action.project.name,
updatedAt: action.project.updatedAt,
owner: action.owner
};
case ActionTypes.SET_PROJECT:
return {
id: action.project.id,
name: action.project.name,
updatedAt: action.project.updatedAt,
owner: action.owner
};
case ActionTypes.RESET_PROJECT:
return initialState();
case ActionTypes.SHOW_EDIT_PROJECT_NAME:
return Object.assign({}, state, { isEditingName: true });
case ActionTypes.HIDE_EDIT_PROJECT_NAME:
return Object.assign({}, state, { isEditingName: false });
case ActionTypes.SET_PROJECT_SAVED_TIME:
return Object.assign({}, state, { updatedAt: action.value });
default:
return state;
}
};
export default project;