feat: unauthenticated tab

This commit is contained in:
2025-11-05 10:58:34 +01:00
parent 8180e0b375
commit e8db8d1654
15 changed files with 229 additions and 58 deletions
+40
View File
@@ -0,0 +1,40 @@
import { getGlobal } from "reactn";
import { navigate } from "../navigation/NavigationService";
import { Routes } from "../navigation/Routes";
const redirectToRegister = () => {
try {
const activeRoute = getGlobal()?.activeRouteName;
if (activeRoute === Routes.Register) {
return;
}
} catch (error) {
console.warn("authRedirect: unable to read active route", error);
}
navigate(Routes.Register);
};
export const ensureAuthenticated = (currentUID, options = {}) => {
const { onIntercept } = options || {};
if (currentUID) {
return true;
}
try {
if (typeof onIntercept === "function") {
onIntercept();
}
} catch (error) {
console.warn("authRedirect: onIntercept error", error);
}
redirectToRegister();
return false;
};
export const withAuthGuard = async (currentUID, handler, options = {}) => {
if (!ensureAuthenticated(currentUID, options)) {
return;
}
return handler?.();
};
export default ensureAuthenticated;