refactor: add validation to prevent run on cloud

This commit is contained in:
Mauricio Siu 2024-11-17 18:23:27 -06:00
parent 04235fb6c9
commit 2307346ae3
2 changed files with 9 additions and 0 deletions

View File

@ -31,6 +31,12 @@ export const adminRouter = createTRPCRouter({
update: adminProcedure
.input(apiUpdateAdmin)
.mutation(async ({ input, ctx }) => {
if (ctx.user.rol === "user") {
throw new TRPCError({
code: "UNAUTHORIZED",
message: "You are not allowed to update this admin",
});
}
const { authId } = await findAdminById(ctx.user.adminId);
return updateAdmin(authId, input);
}),

View File

@ -183,6 +183,9 @@ export const serverRouter = createTRPCRouter({
}
}),
publicIp: protectedProcedure.query(async ({ ctx }) => {
if (IS_CLOUD) {
return "";
}
const ip = await getPublicIpWithFallback();
return ip;
}),