From 6c8ed958f444f702df1bc0d3ce95f1c923378d29 Mon Sep 17 00:00:00 2001 From: sanguu Date: Fri, 23 Sep 2022 11:25:49 +0900 Subject: [PATCH] =?UTF-8?q?=ED=9A=8C=EC=9B=90=ED=83=88=ED=87=B4=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=95=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/account/login/sagas/authSaga.ts | 102 +++++++++++++------- 1 file changed, 69 insertions(+), 33 deletions(-) diff --git a/src/modules/account/login/sagas/authSaga.ts b/src/modules/account/login/sagas/authSaga.ts index 057379e..606ba5d 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(