diff --git a/src/modules/account/login/sagas/authSaga.ts b/src/modules/account/login/sagas/authSaga.ts index 057379e3..606ba5da 100644 --- a/src/modules/account/login/sagas/authSaga.ts +++ b/src/modules/account/login/sagas/authSaga.ts @@ -153,43 +153,75 @@ function* userPageSaga( function* userDeletePageSaga( action: ActionType ) { + // try { + // const controlId = action.payload; + + // const { data } = yield call(authAPI.deletedata, controlId); + // // console.log('userPageData : ', data) + // if (data.errorCode === '-1') { + // yield put( + // MessageActions.IS_ERROR({ + // errorCode: ERROR_MESSAGE.code, + // errorMessage: ERROR_MESSAGE.message, + // isHistoryBack: false, + // isRefresh: false + // }) + // ); + // yield put(Actions.userDeleteAction.success(data)); + // } else { + // yield put( + // MessageActions.IS_MESSAGE({ + // messageCode: SAVE_MESSAGE.code, + // message: SAVE_MESSAGE.message, + // isHistoryBack: false, + // isRefresh: false + // }) + // ); + // cookieStorage.removeCookie(COOKIE_ACCESS_TOKEN); + // cookieStorage.removeCookie(COOKIE_REFRESH_TOKEN); + + // yield put(replace('/')); + // } + // } catch (error) { + // yield put( + // MessageActions.IS_ERROR({ + // errorCode: ERROR_MESSAGE.code, + // errorMessage: '처리 중 에러입니다.', + // isHistoryBack: false, + // isRefresh: false + // }) + // ); + // } + // } + const accessToken = cookieStorage.getCookie(COOKIE_ACCESS_TOKEN); + //console.log('accessToken', accessToken); + try { - const controlId = action.payload; + const controlId = action.payload; + // console.log('dddddddddddddddddddddddddddddddddddd'); + const { data } = yield call(authAPI.deletedata, controlId); - const { data } = yield call(authAPI.deletedata, controlId); - // console.log('userPageData : ', data) - console.log("sdsdsd",data) - if (data.errorCode === '-1') { - yield put( - MessageActions.IS_ERROR({ - errorCode: ERROR_MESSAGE.code, - errorMessage: ERROR_MESSAGE.message, - isHistoryBack: false, - isRefresh: false - }) - ); - yield put(Actions.userDeleteAction.success(data)); - } else { - yield put( - MessageActions.IS_MESSAGE({ - messageCode: SAVE_MESSAGE.code, - message: SAVE_MESSAGE.message, - isHistoryBack: false, - isRefresh: true - }) - ); + if (data.result === true) { + yield put( + MessageActions.IS_MESSAGE({ + messageCode: SAVE_MESSAGE.code, + message: SAVE_MESSAGE.message, + isHistoryBack: false, + isRefresh: false + }) + ); + location.href = '/account/login'; + // yield put(Actions.userDeleteAction.success(data));; + } + + // yield put(Actions.logout.success()); + cookieStorage.removeCookie(COOKIE_ACCESS_TOKEN); + cookieStorage.removeCookie(COOKIE_REFRESH_TOKEN); + yield put(replace('/')); + } catch (error) { + yield put(Actions.logout.failure(error)); } -} catch (error) { - yield put( - MessageActions.IS_ERROR({ - errorCode: ERROR_MESSAGE.code, - errorMessage: '처리 중 에러입니다.', - isHistoryBack: false, - isRefresh: false - }) - ); -} } function* userUpdateSaga( action: ActionType @@ -216,6 +248,10 @@ function* userUpdateSaga( isRefresh: true }) ); + cookieStorage.removeCookie(COOKIE_ACCESS_TOKEN); + cookieStorage.removeCookie(COOKIE_REFRESH_TOKEN); + + yield put(replace('/')); } } catch (error) { yield put(