Skip to content

Commit

Permalink
improve register user
Browse files Browse the repository at this point in the history
  • Loading branch information
bushblade committed Feb 16, 2020
1 parent 57531c1 commit f64c3bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 0 additions & 2 deletions client/src/actions/auth.js
Expand Up @@ -49,8 +49,6 @@ export const register = ({ name, email, password }) => async dispatch => {
type: REGISTER_SUCCESS,
payload: res.data
});

dispatch(loadUser());
} catch (err) {
const errors = err.response.data.errors;

Expand Down
7 changes: 7 additions & 0 deletions client/src/reducers/auth.js
Expand Up @@ -28,6 +28,13 @@ export default function(state = initialState, action) {
user: payload
};
case REGISTER_SUCCESS:
localStorage.setItem('token', payload.token);
return {
...state,
...payload,
isAuthenticated: true,
loading: false
};
case LOGIN_SUCCESS:
localStorage.setItem('token', payload.token);
return {
Expand Down

0 comments on commit f64c3bd

Please sign in to comment.