📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
move logout logic into the logout saga
Blue Mouse629af1f83c1d
diff --git a/app/redux/sagas/actions/index.ts b/app/redux/sagas/actions/index.tsindex 83c4c276d..77b10c40e 100644--- a/app/redux/sagas/actions/index.ts+++ b/app/redux/sagas/actions/index.ts@@ -1,11 +1,9 @@/* eslint-disable no-unused-vars */import types from 'redux/sagas/actions/types'-import { getRefreshToken, removeRefreshToken } from 'utils/refreshToken'import { removeAccessToken } from 'utils/accessToken'import { removeItem } from 'utils/localstorage'import { LS_VIEW_PREFS_SETTING, LS_CAPTCHA_VIEW_PREFS_SETTING } from 'redux/constants'import { IUser } from '../../models/IUser'-const { logoutApi } = require('api')const loadProjects = (take?: number, skip?: number) => ({type: types.LOAD_PROJECTS,@@ -97,9 +95,6 @@ const updateUserProfileAsync = (data: Partial<IUser>, callback = (item: any) =>})const deleteAccountAsync = (errorCallback?: (e: string) => {}, successCallback?: (str?: string) => void, t?: (str: string) => {}) => {- const refreshToken = getRefreshToken()- logoutApi(refreshToken)-return {type: types.DELETE_ACCOUNT_ASYNC,payload: {@@ -117,10 +112,7 @@ const shareVerifyAsync = (data: {})const logout = (basedOn401Error: boolean) => {- const refreshToken = getRefreshToken()- logoutApi(refreshToken)removeAccessToken()- removeRefreshToken()removeItem(LS_VIEW_PREFS_SETTING)removeItem(LS_CAPTCHA_VIEW_PREFS_SETTING)diff --git a/app/redux/sagas/auth/workers/logout.ts b/app/redux/sagas/auth/workers/logout.tsindex 4f7b537f4..997af3468 100644--- a/app/redux/sagas/auth/workers/logout.ts+++ b/app/redux/sagas/auth/workers/logout.ts@@ -3,12 +3,17 @@ import Debug from 'debug'import UIActions from 'redux/reducers/ui'import { IStats } from '../../../models/IStats'-const { getGeneralStats } = require('api')+import { getRefreshToken, removeRefreshToken } from 'utils/refreshToken'+const { getGeneralStats, logoutApi } = require('api')const debug = Debug('swetrix:rx:s:logout')export default function* logoutWorker({ payload: { basedOn401Error } }: { payload: { basedOn401Error: boolean } }) {try {+ const refreshToken = getRefreshToken()+ yield call(logoutApi, refreshToken)+ removeRefreshToken()+if (!basedOn401Error) {const stats: IStats = yield call(getGeneralStats)yield put(UIActions.setGeneralStats(stats))