Skip to content

Commit

Permalink
Replace jsonwebtoken with jwt-decode on client
Browse files Browse the repository at this point in the history
  • Loading branch information
Remchi committed Aug 8, 2016
1 parent b15425c commit ca69ef8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions client/actions/authActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import setAuthorizationToken from '../utils/setAuthorizationToken';
import jwt from 'jsonwebtoken';
import jwtDecode from 'jwt-decode';
import { SET_CURRENT_USER } from './types';

export function setCurrentUser(user) {
Expand All @@ -24,7 +24,7 @@ export function login(data) {
const token = res.data.token;
localStorage.setItem('jwtToken', token);
setAuthorizationToken(token);
dispatch(setCurrentUser(jwt.decode(token)));
dispatch(setCurrentUser(jwtDecode(token)));
});
}
}
4 changes: 2 additions & 2 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import thunk from 'redux-thunk';
import { createStore, applyMiddleware, compose } from 'redux';
import rootReducer from './rootReducer';
import setAuthorizationToken from './utils/setAuthorizationToken';
import jwt from 'jsonwebtoken';
import jwtDecode from 'jwt-decode';
import { setCurrentUser } from './actions/authActions';

import routes from './routes';
Expand All @@ -21,7 +21,7 @@ const store = createStore(

if (localStorage.jwtToken) {
setAuthorizationToken(localStorage.jwtToken);
store.dispatch(setCurrentUser(jwt.decode(localStorage.jwtToken)));
store.dispatch(setCurrentUser(jwtDecode(localStorage.jwtToken)));
}

render(
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"classnames": "^2.2.5",
"express": "^4.14.0",
"jsonwebtoken": "^7.1.7",
"jwt-decode": "^2.1.0",
"knex": "^0.11.7",
"lodash": "^4.13.1",
"pg": "^6.0.2",
Expand Down
4 changes: 0 additions & 4 deletions webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,5 @@ export default {
},
resolve: {
extentions: [ '', '.js' ]
},
node: {
net: 'empty',
dns: 'empty'
}
}

0 comments on commit ca69ef8

Please sign in to comment.