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 })
|
||||
}
|
||||
if (response.status === 200) {
|
||||
console.log(document.cookie)
|
||||
dispatch({ type: 'USER_LOGIN', payload: response })
|
||||
var v = document.cookie.match('(^|;) ?DataCookie=([^;]*)(;|$)');
|
||||
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}
|
||||
case 'USER_LOGIN':
|
||||
if (action.payload) {
|
||||
var data = JSON.parse(atob(action.payload.data.split('.')[1]))
|
||||
var data = JSON.parse(atob(action.payload.split('.')[1]))
|
||||
return {...state, ...{
|
||||
user_authed: true,
|
||||
username: data.username,
|
||||
|
|
Reference in a new issue