feat: add more group permissions (#1453)
* feat: add more group permissions * feat: restrict access with app permissions * feat: restrict access with search-engine permissions * feat: restrict access with media permissions * refactor: remove permissions for users, groups and invites * test: adjust app router tests with app permissions * fix: integration page accessible without session * fix: search for users, groups and integrations shown to unauthenticated users * chore: address pull request feedback
This commit is contained in:
23
apps/nextjs/src/errors/trpc-catch-error.ts
Normal file
23
apps/nextjs/src/errors/trpc-catch-error.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import "server-only";
|
||||
|
||||
import { notFound, redirect } from "next/navigation";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
import { logger } from "@homarr/log";
|
||||
|
||||
export const catchTrpcNotFound = (err: unknown) => {
|
||||
if (err instanceof TRPCError && err.code === "NOT_FOUND") {
|
||||
notFound();
|
||||
}
|
||||
|
||||
throw err;
|
||||
};
|
||||
|
||||
export const catchTrpcUnauthorized = (err: unknown) => {
|
||||
if (err instanceof TRPCError && err.code === "UNAUTHORIZED") {
|
||||
logger.info("Somebody tried to access a protected route without being authenticated, redirecting to login page");
|
||||
redirect("/auth/login");
|
||||
}
|
||||
|
||||
throw err;
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
import "server-only";
|
||||
|
||||
import { notFound } from "next/navigation";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
export const catchTrpcNotFound = (err: unknown) => {
|
||||
if (err instanceof TRPCError && err.code === "NOT_FOUND") {
|
||||
notFound();
|
||||
}
|
||||
|
||||
throw err;
|
||||
};
|
||||
Reference in New Issue
Block a user