mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-10 00:15:28 +02:00
Refactor user role handling in TRPC context and routers
- Updated the user role property from `rol` to `role` across multiple TRPC context and router files to ensure consistency and clarity in role management. - Adjusted conditional checks for user roles in various procedures to reflect the updated property name, enhancing code readability and maintainability.
This commit is contained in:
@@ -30,7 +30,7 @@ import { ZodError } from "zod";
|
||||
*/
|
||||
|
||||
interface CreateContextOptions {
|
||||
user: (User & { rol: "member" | "admin" | "owner"; ownerId: string }) | null;
|
||||
user: (User & { role: "member" | "admin" | "owner"; ownerId: string }) | null;
|
||||
session: (Session & { activeOrganizationId: string }) | null;
|
||||
req: CreateNextContextOptions["req"];
|
||||
res: CreateNextContextOptions["res"];
|
||||
@@ -83,7 +83,7 @@ export const createTRPCContext = async (opts: CreateNextContextOptions) => {
|
||||
? {
|
||||
...user,
|
||||
email: user.email,
|
||||
rol: user.role as "owner" | "member" | "admin",
|
||||
role: user.role as "owner" | "member" | "admin",
|
||||
id: user.id,
|
||||
ownerId: user.ownerId,
|
||||
}
|
||||
@@ -180,7 +180,7 @@ export const uploadProcedure = async (opts: any) => {
|
||||
};
|
||||
|
||||
export const cliProcedure = t.procedure.use(({ ctx, next }) => {
|
||||
if (!ctx.session || !ctx.user || ctx.user.rol !== "owner") {
|
||||
if (!ctx.session || !ctx.user || ctx.user.role !== "owner") {
|
||||
throw new TRPCError({ code: "UNAUTHORIZED" });
|
||||
}
|
||||
return next({
|
||||
@@ -194,7 +194,7 @@ export const cliProcedure = t.procedure.use(({ ctx, next }) => {
|
||||
});
|
||||
|
||||
export const adminProcedure = t.procedure.use(({ ctx, next }) => {
|
||||
if (!ctx.session || !ctx.user || ctx.user.rol !== "owner") {
|
||||
if (!ctx.session || !ctx.user || ctx.user.role !== "owner") {
|
||||
throw new TRPCError({ code: "UNAUTHORIZED" });
|
||||
}
|
||||
return next({
|
||||
|
||||
Reference in New Issue
Block a user