Merge branch '634-issue---logout-is-not-shared-cross-tabs' into 612-disconnect-from-ws-on-logout

This commit is contained in:
yassinedorbozgithub 2025-01-28 11:54:36 +01:00
commit 414afd8e73
2 changed files with 15 additions and 3 deletions

View File

@ -123,12 +123,12 @@ export class SubscriberRepository extends BaseRepository<
* *
* @param id - The foreign ID of the subscriber. * @param id - The foreign ID of the subscriber.
* *
* @returns The found subscriber entity. * @returns The found subscriber entity, or `null` if no subscriber is found.
*/ */
async findOneByForeignId(id: string): Promise<Subscriber> { async findOneByForeignId(id: string): Promise<Subscriber | null> {
const query = this.findByForeignIdQuery(id); const query = this.findByForeignIdQuery(id);
const [result] = await this.execute(query, Subscriber); const [result] = await this.execute(query, Subscriber);
return result; return result || null;
} }
/** /**

View File

@ -21,6 +21,11 @@ import { Progress } from "@/app-components/displays/Progress";
import { useLogout } from "@/hooks/entities/auth-hooks"; import { useLogout } from "@/hooks/entities/auth-hooks";
import { useApiClient } from "@/hooks/useApiClient"; import { useApiClient } from "@/hooks/useApiClient";
import { CURRENT_USER_KEY, PUBLIC_PATHS } from "@/hooks/useAuth"; import { CURRENT_USER_KEY, PUBLIC_PATHS } from "@/hooks/useAuth";
import {
EBCEvent,
ETabMode,
useBroadcastChannel,
} from "@/hooks/useBroadcastChannel";
import { useTranslate } from "@/hooks/useTranslate"; import { useTranslate } from "@/hooks/useTranslate";
import { RouterType } from "@/services/types"; import { RouterType } from "@/services/types";
import { IUser } from "@/types/user.types"; import { IUser } from "@/types/user.types";
@ -59,6 +64,7 @@ export const AuthProvider = ({ children }: AuthProviderProps): JSX.Element => {
i18n.changeLanguage(lang); i18n.changeLanguage(lang);
}; };
const { mutate: logoutSession } = useLogout(); const { mutate: logoutSession } = useLogout();
const { mode, value } = useBroadcastChannel();
const logout = async () => { const logout = async () => {
updateLanguage(publicRuntimeConfig.lang.default); updateLanguage(publicRuntimeConfig.lang.default);
logoutSession(); logoutSession();
@ -107,6 +113,12 @@ export const AuthProvider = ({ children }: AuthProviderProps): JSX.Element => {
setIsReady(true); setIsReady(true);
}, []); }, []);
useEffect(() => {
if (value === EBCEvent.LOGOUT_END_SESSION && mode === ETabMode.SECONDARY) {
router.reload();
}
}, [value, mode, router]);
if (!isReady || isLoading) return <Progress />; if (!isReady || isLoading) return <Progress />;
return ( return (