1
0
Fork 0

Fix up cookie authing

This commit is contained in:
Amarpreet Minhas 2020-01-22 00:46:40 -05:00
parent 5b0c07b09c
commit 1d6c07a223
2 changed files with 4 additions and 3 deletions

View file

@ -28,8 +28,9 @@ export const userLogin = (username, password) => async (dispatch) => {
dispatch({ type: 'USER_LOGIN', payload: null }) dispatch({ type: 'USER_LOGIN', payload: null })
} }
if (response.status === 200) { if (response.status === 200) {
console.log(document.cookie) var v = document.cookie.match('(^|;) ?DataCookie=([^;]*)(;|$)');
dispatch({ type: 'USER_LOGIN', payload: response }) var DataCookie = v ? v[2] : null;
dispatch({ type: 'USER_LOGIN', payload: DataCookie})
} }
}; };

View file

@ -11,7 +11,7 @@ export default (state = initialState, action) => {
return {...state, ...action.data} return {...state, ...action.data}
case 'USER_LOGIN': case 'USER_LOGIN':
if (action.payload) { if (action.payload) {
var data = JSON.parse(atob(action.payload.data.split('.')[1])) var data = JSON.parse(atob(action.payload.split('.')[1]))
return {...state, ...{ return {...state, ...{
user_authed: true, user_authed: true,
username: data.username, username: data.username,