Skip to content

Commit a89f9db

Browse files
committed
Redirect to login page for anonymous users
1 parent 73fa8a7 commit a89f9db

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

llmstack/client/src/App.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import { useRecoilState, useRecoilValue } from "recoil";
88
import BannerMessages from "./components/BannerMessages";
99
import NavBar from "./components/navbar";
1010
import Sidebar from "./components/sidebar";
11-
import { isMobileState, profileFlagsSelector } from "./data/atoms";
11+
import {
12+
isMobileState,
13+
profileFlagsSelector,
14+
isLoggedInState,
15+
} from "./data/atoms";
1216

1317
const menuItems = [
1418
{
@@ -40,6 +44,7 @@ const menuItems = [
4044

4145
export default function App({ children }) {
4246
const location = useLocation();
47+
const isLoggedIn = useRecoilValue(isLoggedInState);
4348
const [_, setCookie] = useCookies(["irclickid"]); // eslint-disable-line
4449

4550
let allMenuItems = menuItems;
@@ -120,6 +125,15 @@ export default function App({ children }) {
120125
});
121126
}
122127

128+
if (
129+
!process.env.REACT_APP_ENABLE_SUBSCRIPTION_MANAGEMENT &&
130+
!location.pathname.startsWith("/app/") &&
131+
!isLoggedIn
132+
) {
133+
// Redirect to login page if user is not logged in
134+
window.location.href = "/login";
135+
}
136+
123137
return (
124138
<div id="app-container">
125139
<SnackbarProvider

0 commit comments

Comments
 (0)