Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default function App(): React.ReactElement {
ckey: "debug",
email: "debug@debug.debug",
groups: ["admin"],
manageable: ["mentor"],
isStaff: true,
isManagement: true,
});
Expand Down Expand Up @@ -68,6 +69,32 @@ export default function App(): React.ReactElement {
.catch((error) => {
console.error("Auth error:", error);
window.location.href = "/api/auth/login";
setAuthLoading(false);
return;
});

// Fetch allowed groups from backend
fetch(`${apiPath}/Authentik/AllowedGroups`, {
credentials: "include",
})
.then((response) => {
if (!response.ok) {
throw new Error("Failed to fetch allowed groups");
}
return response.json();
})
.then((json: { manageable: string[] }) => {
setUser((exitingUser) => {
if (exitingUser) {
return {
...exitingUser,
manageable: json.manageable,
};
}
});
})
.catch((error) => {
console.error("Auth error:", error);
})
.finally(() => {
setAuthLoading(false);
Expand Down Expand Up @@ -147,7 +174,7 @@ export default function App(): React.ReactElement {
</LinkColor>
</>
)}
{user?.isManagement && (
{user?.manageable?.length && (
<>
|
<LinkColor>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type User = {
ckey: string;
email: string;
groups: string[];
manageable: string[];
isStaff: boolean;
isManagement: boolean;
};
Expand Down