Skip to content

📈 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!

fixed logout

Blue Mouse8d5daef76532
diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx
index a16aa5aa1..4009b36cc 100644
--- a/src/components/Header/index.tsx
+++ b/src/components/Header/index.tsx
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types'
import { Link, NavLink } from 'react-router-dom'
import { HashLink } from 'react-router-hash-link'
import { useAppDispatch } from 'redux/store'
+import { useDispatch } from 'react-redux'
import { useTranslation } from 'react-i18next'
import Flag from 'react-flagkit'
import i18next from 'i18next'
@@ -26,6 +27,7 @@ import cx from 'clsx'
import routes from 'routes'
import { authActions } from 'redux/reducers/auth'
+import sagaActions from 'redux/sagas/actions'
import UIActions from 'redux/reducers/ui'
import {
whitelist, languages, languageFlag, isSelfhosted, BLOG_URL,
@@ -537,6 +539,7 @@ const Header = ({
i18n: { language: string },
} = useTranslation('common')
const dispatch = useAppDispatch()
+ const _dispatch = useDispatch()
// @ts-ignore
const buttonRef: MutableRefObject<HTMLButtonElement> = useRef<HTMLButtonElement>()
@@ -576,6 +579,7 @@ const Header = ({
const logoutHandler = () => {
dispatch(authActions.logout())
+ _dispatch(sagaActions.logout(false))
}
const switchTheme = (_theme?: string) => {
diff --git a/src/redux/sagas/actions/index.ts b/src/redux/sagas/actions/index.ts
index ad37afa49..ef2798fad 100644
--- a/src/redux/sagas/actions/index.ts
+++ b/src/redux/sagas/actions/index.ts
@@ -32,8 +32,8 @@ const loadProjectAlerts = (take?: number, skip?: number) => ({
})
const loginAsync = (credentials: {
- email: string,
- password: string,
+ email: string,
+ password: string,
}, callback = () => { }) => ({
type: types.LOGIN_ASYNC,
payload: {
@@ -42,8 +42,8 @@ const loginAsync = (credentials: {
})
const signupAsync = (data: {
- email: string,
- password: string,
+ email: string,
+ password: string,
}, t?: (string: string) => {}, callback = (res: any) => { }) => ({
type: types.SIGNUP_ASYNC,
payload: {
@@ -52,13 +52,13 @@ const signupAsync = (data: {
})
const emailVerifyAsync = (data: {
- id: string,
+ id: string,
}, successfulCallback?: () => void, errorCallback?: (e: string) => void) => ({
type: types.EMAIL_VERIFY_ASYNC,
payload: { data, successfulCallback, errorCallback },
})
-const updateUserProfileAsync = (data: Partial<IUser>, callback = (item: any) => {}) => ({
+const updateUserProfileAsync = (data: Partial<IUser>, callback = (item: any) => { }) => ({
type: types.UPDATE_USER_PROFILE_ASYNC,
payload: { data, callback },
})
@@ -76,14 +76,14 @@ const deleteAccountAsync = (errorCallback?: (e: string) => {}, successCallback?:
}
const shareVerifyAsync = (data: {
- id: string,
- path: string
+ id: string,
+ path: string
}, successfulCallback?: () => void, errorCallback?: (error: string) => void) => ({
type: types.SHARE_VERIFY_ASYNC,
payload: { data, successfulCallback, errorCallback },
})
-const logout = (basedOn401Error: string) => {
+const logout = (basedOn401Error: boolean) => {
const refreshToken = getRefreshToken()
logoutApi(refreshToken)
removeAccessToken()
diff --git a/src/utils/cookie.ts b/src/utils/cookie.ts
index 7db8f1b7f..fbde215a7 100644
--- a/src/utils/cookie.ts
+++ b/src/utils/cookie.ts
@@ -4,6 +4,8 @@ const COOKIE_DOMAIN = 'swetrix.com'
const COOKIE_SUFFIX = isDevelopment ? '' : `; domain=${COOKIE_DOMAIN}; secure`
+// const COOKIE_SUFFIX = '; domain=swetrix.com; secure'
+
export const getCookie = (key: string) => {
const match = document.cookie.match(new RegExp(`(^| )${key}=([^;]+)`))