diff --git a/app/components/Routes/AdminRoute.js b/app/components/Routes/AdminRoute.js index f346cd2c7e..30a3027169 100644 --- a/app/components/Routes/AdminRoute.js +++ b/app/components/Routes/AdminRoute.js @@ -1,20 +1,26 @@ import React, { PropTypes } from 'react'; +import cookie from 'react-cookie'; import { Route, Redirect } from 'react-router-dom'; const AdminRoute = ({ component, ...rest }) => ( ( - window.admin ? ( - React.createElement(component, props) - ) : ( - - ) - )} + {...rest} render={(props) => { + if (!window.id) { // checks for non authenticated accounts + cookie.save('target', props.location.pathname, { path: '/' }); + } + return ( + window.admin ? ( + React.createElement(component, props) + ) : ( + + ) + ); + }} /> ); diff --git a/app/components/Routes/PrivateRoute.js b/app/components/Routes/PrivateRoute.js index cb7602586b..a739358e83 100644 --- a/app/components/Routes/PrivateRoute.js +++ b/app/components/Routes/PrivateRoute.js @@ -1,20 +1,26 @@ import React, { PropTypes } from 'react'; +import cookie from 'react-cookie'; import { Route, Redirect } from 'react-router-dom'; const PrivateRoute = ({ component, ...rest }) => ( ( - window.id ? ( - React.createElement(component, props) - ) : ( - - ) - )} + {...rest} render={(props) => { + if (!window.id) { // checks for non authenticated accounts + cookie.save('target', props.location.pathname, { path: '/' }); + } + return ( + window.id ? ( + React.createElement(component, props) + ) : ( + + ) + ); + }} /> ); diff --git a/app/data/github.js b/app/data/github.js index 87ec3d8061..73190bcc23 100644 --- a/app/data/github.js +++ b/app/data/github.js @@ -49,7 +49,7 @@ const data = [ { /* find . | grep ".js" | grep -vE ".min.js|node_modules|.git|.json" | xargs -I file cat file | wc -l */ label: 'Lines of Javascript powering this website', - value: '2531', + value: '2543', link: 'https://github.com/mldangelo/mldangelo/graphs/contributors', }, ]; diff --git a/package.json b/package.json index e2c65e3444..8e68769386 100644 --- a/package.json +++ b/package.json @@ -37,14 +37,14 @@ "express": "^4.15.2", "express-session": "^1.15.2", "extract-text-webpack-plugin": "^2.1.0", - "file-loader": "^0.11.0", + "file-loader": "^0.11.1", "forever": "^0.15.3", "github": "9.2.0", "html-minify-loader": "^1.1.0", "html-webpack-plugin": "^2.28.0", "last.fm.api": "^0.1.3", "moment": "^2.18.1", - "mongoose": "^4.9.2", + "mongoose": "^4.9.3", "morgan": "^1.8.1", "node-sass": "^4.5.2", "nodemon": "^1.11.0", @@ -54,6 +54,7 @@ "raw-loader": "^0.5.1", "react": "^15.4.2", "react-burger-menu": "^1.10.14", + "react-cookie": "^1.0.5", "react-dom": "^15.4.2", "react-ga": "^2.1.2", "react-helmet": "^5.0.2", @@ -69,7 +70,7 @@ "url-loader": "^0.5.8", "webpack": "^2.3.2", "webpack-dev-middleware": "^1.10.1", - "webpack-hot-middleware": "^2.17.1" + "webpack-hot-middleware": "^2.18.0" }, "devDependencies": { "babel-eslint": "^7.2.1", diff --git a/server/routes/index.js b/server/routes/index.js index d12db2e967..0c1426a2e9 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -10,10 +10,9 @@ const routes = (app) => { app.get('/login/google/return', passport.authenticate('google', { failureRedirect: '/login', }), (req, res) => { - if (req.user && req.user.isAdmin) { - return res.redirect('/admin'); // redirect to admin dash for admin accounts - } - return res.redirect('/resume'); // the only other protected page. this works for now + const target = req.cookies.target || '/'; + res.clearCookie('target', { path: '/' }); + return res.redirect(target); }); app.get('/logout', require('./views/logout')); diff --git a/yarn.lock b/yarn.lock index 0a54e44aeb..ebc2582db2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -269,9 +269,9 @@ aws4@^1.2.1: version "1.6.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" -axios@^0.15.3: - version "0.15.3" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.15.3.tgz#2c9d638b2e191a08ea1d6cc988eadd6ba5bdc053" +axios@^0.16.0: + version "0.16.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.16.0.tgz#6ed9771d815f429e7510f2838262957c4953d3b6" dependencies: follow-redirects "1.0.0" @@ -1530,7 +1530,7 @@ cookie-signature@1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" -cookie@0.3.1: +cookie@0.3.1, cookie@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" @@ -2275,9 +2275,9 @@ eslint-plugin-react@^6.10.3: jsx-ast-utils "^1.3.4" object.assign "^4.0.4" -eslint@^3.18.0: - version "3.18.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.18.0.tgz#647e985c4ae71502d20ac62c109f66d5104c8a4b" +eslint@^3.19.0: + version "3.19.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc" dependencies: babel-code-frame "^6.16.0" chalk "^1.1.3" @@ -2326,10 +2326,6 @@ esprima@^2.6.0: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" -esprima@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" - esprima@~1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/esprima/-/esprima-1.0.4.tgz#9f557e08fc3b4d26ece9dd34f8fbf476b62585ad" @@ -2557,9 +2553,9 @@ file-entry-cache@^2.0.0: flat-cache "^1.2.1" object-assign "^4.0.1" -file-loader@^0.10.1: - version "0.10.1" - resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-0.10.1.tgz#815034119891fc6441fb5a64c11bc93c22ddd842" +file-loader@^0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-0.11.1.tgz#6b328ee1234a729e4e47d36375dd6d35c0e1db84" dependencies: loader-utils "^1.0.2" @@ -3283,6 +3279,10 @@ is-my-json-valid@^2.10.0: jsonpointer "^4.0.0" xtend "^4.0.0" +is-node@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-node/-/is-node-1.0.2.tgz#d7d002745ef7debbb7477e988956ab0a4fccb653" + is-npm@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" @@ -3416,14 +3416,7 @@ js-tokens@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" -js-yaml@^3.5.1: - version "3.8.2" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.2.tgz#02d3e2c0f6beab20248d412c352203827d786721" - dependencies: - argparse "^1.0.7" - esprima "^3.1.1" - -js-yaml@~3.7.0: +js-yaml@^3.5.1, js-yaml@~3.7.0: version "3.7.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.7.0.tgz#5c967ddd837a9bfdca5f2de84253abe8a1c03b80" dependencies: @@ -5061,6 +5054,14 @@ react-burger-menu@^1.10.14: radium "^0.18.1" snapsvg-cjs "0.0.4" +react-cookie@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/react-cookie/-/react-cookie-1.0.5.tgz#234190bd55ddfea361444a89c873077ab6abf651" + dependencies: + cookie "^0.3.1" + is-node "^1.0.2" + object-assign "^4.1.0" + react-dom@^15.4.2: version "15.4.2" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.4.2.tgz#015363f05b0a1fd52ae9efdd3a0060d90695208f" @@ -5493,11 +5494,11 @@ semver-diff@^2.0.0: dependencies: semver "^5.0.3" -"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.3.0, semver@~5.3.0: +"semver@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@~5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" -semver@^5.0.3, semver@~5.0.1: +semver@~5.0.1: version "5.0.3" resolved "https://registry.yarnpkg.com/semver/-/semver-5.0.3.tgz#77466de589cd5d3c95f138aa78bc569a3cb5d27a"