From 40cb1607402ada2681e38d23eb74c0d6af4ae671 Mon Sep 17 00:00:00 2001 From: Asara Date: Sat, 5 Oct 2019 21:24:02 -0400 Subject: [PATCH] Add with creds to post --- src/actions/index.js | 6 ++++-- src/reducers/authReducer.js | 17 ----------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index 0959fec..46322ac 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -22,9 +22,11 @@ export const userLogin = (username, password) => async (dispatch) => { const response = await sudoscientist.post('/auth/signin', { username: username, password: password - }) + }, + {withCredentials: true}, + ) if (response.status === 401) { - alert("Please check your credentials") + console.log("Please check your credentials") } if (response.status === 200) { dispatch({ type: 'USER_LOGIN', payload: response }) diff --git a/src/reducers/authReducer.js b/src/reducers/authReducer.js index 7ae725b..ef1c28a 100644 --- a/src/reducers/authReducer.js +++ b/src/reducers/authReducer.js @@ -1,7 +1,3 @@ -import Cookies from 'universal-cookie'; - -const cookies = new Cookies(); - const initialState = { user_logged_in: false, username: '', @@ -12,19 +8,6 @@ const initialState = { export default (state = initialState, action) => { switch (action.type) { case 'USER_LOGIN': - const full_jwt = action.payload.data.jwt - const jwt_split = full_jwt.split('.') - const jwt_signature = jwt_split.pop() - const jwt_header_payload = jwt_split.join('.') - cookies.set("jwt.signature", jwt_signature, - { - path: '/', - httpOnly: true - }) - cookies.set("jwt.header_payload", jwt_header_payload, - { - path: '/', - }) return {...state, ...{ username: action.payload.data.username, user_logged_in: true