p5.js-web-editor/server/routes/server.routes.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

63 lines
1.5 KiB
JavaScript

import { Router } from 'express';
import { renderIndex } from '../views/index';
import { get404Sketch } from '../views/404Page';
import { userExists } from '../controllers/user.controller';
const router = new Router();
// this is intended to be a temporary file
// until i figure out isomorphic rendering
router.route('/').get((req, res) => {
res.send(renderIndex());
});
router.route('/signup').get((req, res) => {
res.send(renderIndex());
});
router.route('/projects/:project_id').get((req, res) => {
res.send(renderIndex());
});
router.route('/:username/sketches/:project_id').get((req, res) => {
res.send(renderIndex());
});
// router.route('/full/:project_id').get((req, res) => {
// res.send(renderIndex());
// });
router.route('/login').get((req, res) => {
res.send(renderIndex());
});
router.route('/reset-password').get((req, res) => {
res.send(renderIndex());
});
router.route('/reset-password/:reset_password_token').get((req, res) => {
res.send(renderIndex());
});
router.route('/sketches').get((req, res) => {
res.send(renderIndex());
});
router.route('/about').get((req, res) => {
res.send(renderIndex());
});
router.route('/:username/sketches').get((req, res) => {
userExists(req.params.username, exists => (
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
));
});
router.route('/:username/account').get((req, res) => {
userExists(req.params.username, exists => (
exists ? res.send(renderIndex()) : get404Sketch(html => res.send(html))
));
});
export default router;