Fix up cookie authing
This commit is contained in:
parent
5b0c07b09c
commit
1d6c07a223
2 changed files with 4 additions and 3 deletions
|
@ -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})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Reference in a new issue