mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
Merge branch '634-issue---logout-is-not-shared-cross-tabs' into 612-disconnect-from-ws-on-logout
This commit is contained in:
commit
414afd8e73
@ -123,12 +123,12 @@ export class SubscriberRepository extends BaseRepository<
|
||||
*
|
||||
* @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 [result] = await this.execute(query, Subscriber);
|
||||
return result;
|
||||
return result || null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -21,6 +21,11 @@ import { Progress } from "@/app-components/displays/Progress";
|
||||
import { useLogout } from "@/hooks/entities/auth-hooks";
|
||||
import { useApiClient } from "@/hooks/useApiClient";
|
||||
import { CURRENT_USER_KEY, PUBLIC_PATHS } from "@/hooks/useAuth";
|
||||
import {
|
||||
EBCEvent,
|
||||
ETabMode,
|
||||
useBroadcastChannel,
|
||||
} from "@/hooks/useBroadcastChannel";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { RouterType } from "@/services/types";
|
||||
import { IUser } from "@/types/user.types";
|
||||
@ -59,6 +64,7 @@ export const AuthProvider = ({ children }: AuthProviderProps): JSX.Element => {
|
||||
i18n.changeLanguage(lang);
|
||||
};
|
||||
const { mutate: logoutSession } = useLogout();
|
||||
const { mode, value } = useBroadcastChannel();
|
||||
const logout = async () => {
|
||||
updateLanguage(publicRuntimeConfig.lang.default);
|
||||
logoutSession();
|
||||
@ -107,6 +113,12 @@ export const AuthProvider = ({ children }: AuthProviderProps): JSX.Element => {
|
||||
setIsReady(true);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (value === EBCEvent.LOGOUT_END_SESSION && mode === ETabMode.SECONDARY) {
|
||||
router.reload();
|
||||
}
|
||||
}, [value, mode, router]);
|
||||
|
||||
if (!isReady || isLoading) return <Progress />;
|
||||
|
||||
return (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user