Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions client/components/createRedirectWithUsername.jsx

This file was deleted.

30 changes: 5 additions & 25 deletions client/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ import NewPasswordView from './modules/User/pages/NewPasswordView';
import AccountView from './modules/User/pages/AccountView';
import CollectionView from './modules/User/pages/CollectionView';
import DashboardView from './modules/User/pages/DashboardView';
import createRedirectWithUsername from './components/createRedirectWithUsername';
import { getUser } from './modules/User/actions';
import {
userIsAuthenticated,
userIsNotAuthenticated,
userIsAuthorized
} from './utils/auth';

/**
* `params` is no longer a top-level route component prop in v4.
Expand Down Expand Up @@ -51,25 +45,19 @@ Route.propTypes = {
const routes = (
<Switch>
<Route exact path="/" component={IDEView} />
<Route path="/login" component={userIsNotAuthenticated(LoginView)} />
<Route path="/signup" component={userIsNotAuthenticated(SignupView)} />
<Route path="/login" component={LoginView} />
<Route path="/signup" component={SignupView} />
<Route
path="/reset-password/:reset_password_token"
component={NewPasswordView}
/>
<Route
path="/reset-password"
component={userIsNotAuthenticated(ResetPasswordView)}
/>
<Route path="/reset-password" component={ResetPasswordView} />
<Route path="/verify" component={EmailVerificationView} />
<Route path="/projects/:project_id" component={IDEView} />
<Route path="/:username/full/:project_id" component={FullView} />
<Route path="/full/:project_id" component={FullView} />

<Route
path="/:username/assets"
component={userIsAuthenticated(userIsAuthorized(DashboardView))}
/>
<Route path="/:username/assets" component={DashboardView} />
<Route
path="/:username/sketches/:project_id/add-to-collection"
component={IDEView}
Expand All @@ -82,15 +70,7 @@ const routes = (
/>
<Route path="/:username/collections" component={DashboardView} />

<Route
path="/sketches"
component={createRedirectWithUsername('/:username/sketches')}
/>
<Route
path="/assets"
component={createRedirectWithUsername('/:username/assets')}
/>
<Route path="/account" component={userIsAuthenticated(AccountView)} />
<Route path="/account" component={AccountView} />
<Route path="/about" component={IDEView} />

<Route path="/privacy-policy" component={PrivacyPolicy} />
Expand Down
30 changes: 0 additions & 30 deletions client/utils/auth.js

This file was deleted.

14 changes: 10 additions & 4 deletions server/routes/server.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,17 @@ router.get('/login', (req, res) => {
});

router.get('/reset-password', (req, res) => {
res.send(renderIndex());
if (req.user) {
return res.redirect('/account');
}
return res.send(renderIndex());
});

router.get('/reset-password/:reset_password_token', (req, res) => {
res.send(renderIndex());
if (req.user) {
return res.redirect('/account');
}
return res.send(renderIndex());
});

router.get('/verify', (req, res) => {
Expand All @@ -89,15 +95,15 @@ router.get('/verify', (req, res) => {

router.get('/sketches', (req, res) => {
if (req.user) {
res.send(renderIndex());
res.redirect(`/${req.user.username}/sketches`);
} else {
res.redirect('/login');
}
});

router.get('/assets', (req, res) => {
if (req.user) {
res.send(renderIndex());
res.redirect(`/${req.user.username}/assets`);
} else {
res.redirect('/login');
}
Expand Down