feat: tambah pengecekan isActive dan bersihkan cache saat logout

- Tampilkan Alert jika admin menonaktifkan akun user yang sedang login
- Clear React Query cache saat signOut agar data akun lama tidak bocor ke sesi berikutnya

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-22 15:17:21 +08:00
parent f39d5a4c85
commit 6c9623954c
2 changed files with 14 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ import { ConstEnv } from '@/constants/ConstEnv';
import { apiRegisteredToken, apiUnregisteredToken } from '@/lib/api';
import { getToken } from '@/lib/useNotification';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useQueryClient } from '@tanstack/react-query';
import CryptoES from "crypto-es";
import { router } from "expo-router";
import { createContext, MutableRefObject, ReactNode, useCallback, useContext, useEffect, useRef, useState } from 'react';
@@ -30,6 +31,7 @@ export function useAuthSession() {
export default function AuthProvider({ children }: { children: ReactNode }): ReactNode {
const tokenRef = useRef<string | null>(null);
const [isLoading, setIsLoading] = useState(true);
const queryClient = useQueryClient();
useEffect(() => {
(async (): Promise<void> => {
@@ -87,6 +89,7 @@ export default function AuthProvider({ children }: { children: ReactNode }): Rea
} finally {
await AsyncStorage.setItem('@token', '');
tokenRef.current = null;
queryClient.clear();
router.replace('/');
}
}, []);