mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-24 15:25:23 +02:00
Add impersonation feature to user management
- Introduced an ImpersonationBar component for admin users to impersonate other users, enhancing user management capabilities. - Updated the ProfileForm to include an option for allowing impersonation, with a description for clarity. - Modified the DashboardLayout to conditionally display the impersonation bar based on user roles and cloud settings. - Added database schema changes to support the new impersonation feature, including a new column for allowImpersonation in the user table. - Implemented necessary API updates to handle impersonation actions and user data retrieval.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
IS_CLOUD,
|
||||
auth,
|
||||
createApiKey,
|
||||
findOrganizationById,
|
||||
findUserById,
|
||||
@@ -91,6 +92,42 @@ export const userRouter = createTRPCRouter({
|
||||
|
||||
return memberResult;
|
||||
}),
|
||||
listUsers: adminProcedure
|
||||
.input(
|
||||
z.object({
|
||||
search: z.string().optional(),
|
||||
}),
|
||||
)
|
||||
.query(async ({ ctx, input }) => {
|
||||
try {
|
||||
console.log(process.env.USER_ADMIN_ID, ctx.user.id);
|
||||
if (process.env.USER_ADMIN_ID !== ctx.user.id) {
|
||||
return [];
|
||||
}
|
||||
const users = await auth.listUsers({
|
||||
query: {
|
||||
limit: 100,
|
||||
filterField: "allowImpersonation",
|
||||
filterOperator: "eq",
|
||||
filterValue: true,
|
||||
...(input.search && {
|
||||
searchField: "email",
|
||||
searchOperator: "contains",
|
||||
searchValue: input.search,
|
||||
}),
|
||||
},
|
||||
// @ts-ignore
|
||||
headers: {
|
||||
cookie: ctx.req.headers.cookie,
|
||||
},
|
||||
});
|
||||
console.log(users);
|
||||
return users;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw error;
|
||||
}
|
||||
}),
|
||||
getBackups: adminProcedure.query(async ({ ctx }) => {
|
||||
const memberResult = await db.query.member.findFirst({
|
||||
where: and(
|
||||
|
||||
Reference in New Issue
Block a user