mirror of
https://github.com/Stef-00012/Zipline-Android-App.git
synced 2025-05-11 10:25:59 +02:00
16 lines
No EOL
479 B
TypeScript
16 lines
No EOL
479 B
TypeScript
import { isAuthenticated } from "@/functions/zipline/auth";
|
|
import { useFocusEffect, useRouter } from "expo-router";
|
|
|
|
export const useAuth = (adminOnly = false) => {
|
|
const router = useRouter()
|
|
|
|
useFocusEffect(() => {
|
|
(async () => {
|
|
const authenticated = await isAuthenticated();
|
|
|
|
if (!authenticated) return router.replace("/login");
|
|
|
|
if (adminOnly && authenticated === "USER") return router.replace("/")
|
|
})();
|
|
});
|
|
} |