diff --git a/client/components/Nav.jsx b/client/components/Nav.jsx
index 253146b0..31b7e5b8 100644
--- a/client/components/Nav.jsx
+++ b/client/components/Nav.jsx
@@ -576,7 +576,7 @@ class Nav extends React.PureComponent {
{
+ React.useEffect(() => {
+ if (username == null) {
+ return;
+ }
+
+ browserHistory.replace(url.replace(':username', username));
+ }, [username]);
+
+ return null;
+};
+
+function mapStateToProps(state) {
+ return {
+ username: state.user ? state.user.username : null,
+ };
+}
+
+const ConnectedRedirectToUser = connect(mapStateToProps)(RedirectToUser);
+
+const createRedirectWithUsername = (url) => (props) => ;
+
+export default createRedirectWithUsername;
diff --git a/client/routes.jsx b/client/routes.jsx
index 0bcad82b..89db6977 100644
--- a/client/routes.jsx
+++ b/client/routes.jsx
@@ -10,7 +10,7 @@ import EmailVerificationView from './modules/User/pages/EmailVerificationView';
import NewPasswordView from './modules/User/pages/NewPasswordView';
import AccountView from './modules/User/pages/AccountView';
import DashboardView from './modules/User/pages/DashboardView';
-// import SketchListView from './modules/Sketch/pages/SketchListView';
+import createRedirectWithUsername from './components/createRedirectWithUsername';
import { getUser } from './modules/User/actions';
import { stopSketch } from './modules/IDE/actions/ide';
@@ -36,11 +36,13 @@ const routes = store => (
-
-
+
+
+
+
diff --git a/server/routes/server.routes.js b/server/routes/server.routes.js
index adade10d..41d7dc60 100644
--- a/server/routes/server.routes.js
+++ b/server/routes/server.routes.js
@@ -79,6 +79,16 @@ router.get('/assets', (req, res) => {
}
});
+router.get('/:username/assets', (req, res) => {
+ userExists(req.params.username, (exists) => {
+ const isLoggedInUser = req.user && req.user.username === req.params.username;
+ const canAccess = exists && isLoggedInUser;
+ return canAccess ?
+ res.send(renderIndex()) :
+ get404Sketch(html => res.send(html));
+ });
+});
+
router.get('/account', (req, res) => {
if (req.user) {
res.send(renderIndex());