Skip to content

Commit 653f8f2

Browse files
committed
feat: enforce admin access control across multiple pages
1 parent 343a289 commit 653f8f2

File tree

6 files changed

+10
-19
lines changed

6 files changed

+10
-19
lines changed

src/app/layout.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,6 @@ const inter = Inter({
2828
display: "swap",
2929
})
3030

31-
/**
32-
* Override console error and warn in development to log to console.log
33-
*/
34-
if (process.env.NODE_ENV === "development" && typeof window !== "undefined") {
35-
console.error = (...args: unknown[]) => {
36-
console.log(args)
37-
}
38-
39-
console.error.bind(console);
40-
console.warn.bind(console);
41-
}
4231

4332
/**
4433
* Mapping of error codes to their descriptions

src/packages/ce/src/dashboard/application/ApplicationSettingsPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const ApplicationSettingsPage: React.FC = () => {
2929
const currentUser = React.useMemo(() => userService.getById(currentSession?.user?.id), [userStore, currentSession])
3030

3131
if (currentUser && !currentUser.admin) {
32-
return notFound()
32+
notFound()
3333
}
3434

3535
return <>

src/packages/ce/src/dashboard/application/RuntimeCreatePage.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
TextInput,
1111
toast,
1212
useForm,
13-
useService, useStore,
13+
useService,
14+
useStore,
1415
useUserSession
1516
} from "@code0-tech/pictor";
1617
import Link from "next/link";
@@ -25,12 +26,13 @@ export const RuntimeCreatePage: React.FC = () => {
2526
const [token, setToken] = React.useState<string | null | undefined>(undefined)
2627
const router = useRouter()
2728
const currentSession = useUserSession()
29+
2830
const userStore = useStore(UserService)
2931
const userService = useService(UserService)
3032
const currentUser = React.useMemo(() => userService.getById(currentSession?.user?.id), [userStore, currentSession])
3133

3234
if (currentUser && !currentUser.admin) {
33-
return notFound()
35+
notFound()
3436
}
3537

3638
const [inputs, validate] = useForm({
@@ -56,7 +58,7 @@ export const RuntimeCreatePage: React.FC = () => {
5658
}).then(payload => {
5759
if ((payload?.errors?.length ?? 0) <= 0) {
5860
if (payload?.runtime?.token) {
59-
setToken(payload.runtime.token)
61+
if (!token) setToken(payload.runtime.token)
6062
} else {
6163
toast({
6264
title: "The runtime was created but no token was provided.",

src/packages/ce/src/dashboard/application/RuntimeSettingPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ export const RuntimeSettingPage: React.FC = () => {
3838
const runtime = React.useMemo(() => runtimeService.getById(`gid://sagittarius/Runtime/${params.runtimeId as any}`), [runtimeStore, params])
3939

4040
if (currentUser && !currentUser.admin) {
41-
return notFound()
41+
notFound()
4242
}
4343

4444
if (runtime?.userAbilities && (!runtime?.userAbilities?.updateRuntime || !runtime.userAbilities.deleteRuntime || !runtime.userAbilities.rotateRuntimeToken)) {
45-
return notFound()
45+
notFound()
4646
}
4747

4848
const initialValues = React.useMemo(() => ({

src/packages/ce/src/dashboard/application/RuntimesPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const RuntimesPage: React.FC = () => {
2626
const currentUser = React.useMemo(() => userService.getById(currentSession?.user?.id), [userStore, currentSession])
2727

2828
if (currentUser && !currentUser.admin) {
29-
return notFound()
29+
notFound()
3030
}
3131

3232
return <>

src/packages/ce/src/dashboard/application/UsersPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const UsersPage: React.FC = () => {
2020
const currentUser = React.useMemo(() => userService.getById(currentSession?.user?.id), [userStore, currentSession])
2121

2222
if (currentUser && !currentUser.admin) {
23-
return notFound()
23+
notFound()
2424
}
2525

2626
return <>

0 commit comments

Comments
 (0)