mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-04 13:35:22 +02:00
feat: add credentials-based user provisioning alongside invitation flow
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
createApiKey,
|
||||
createOrganizationUserWithCredentials,
|
||||
findNotificationById,
|
||||
findOrganizationById,
|
||||
findUserById,
|
||||
@@ -495,6 +496,37 @@ export const userRouter = createTRPCRouter({
|
||||
|
||||
return organizations.length;
|
||||
}),
|
||||
createUserWithCredentials: adminProcedure
|
||||
.input(
|
||||
z.object({
|
||||
email: z.string().email(),
|
||||
password: z.string().min(8),
|
||||
role: z.enum(["member", "admin"]),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
if (IS_CLOUD) {
|
||||
throw new TRPCError({
|
||||
code: "FORBIDDEN",
|
||||
message:
|
||||
"Creating users with initial credentials is only available in self-hosted mode",
|
||||
});
|
||||
}
|
||||
|
||||
if (!ctx.session.activeOrganizationId) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
message: "Active organization is required",
|
||||
});
|
||||
}
|
||||
|
||||
return await createOrganizationUserWithCredentials({
|
||||
organizationId: ctx.session.activeOrganizationId,
|
||||
email: input.email,
|
||||
password: input.password,
|
||||
role: input.role,
|
||||
});
|
||||
}),
|
||||
sendInvitation: adminProcedure
|
||||
.input(
|
||||
z.object({
|
||||
|
||||
Reference in New Issue
Block a user