* remove event type requires confirmation * allow sms sending also for team (frontend) * allow text to attendee for team (backend) * add rate limiting for SMS (WIP) * add functionality to lock and unlock SMS sending (+admin UI view) * rename to smsLockState * add ability to lock users and teams * don't send sms if locked * add missing imports * fix rate limit namespace * add translation * fix type error * remove prop from UsersTable * add smsLockState to buildUser * code clean up * create seperate sms rate limit function * fix type error * add missing userId and teamId to sendSMS * code improvements * add User Team type * fix marking as reviewed * check monthly sms limit only for user * don't lock orgs * fix type error * fix avatars * fix type error * fix type error * fix type error --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
66 lines
2.4 KiB
TypeScript
66 lines
2.4 KiB
TypeScript
import { z } from "zod";
|
|
|
|
import { authedAdminProcedure } from "../../../procedures/authedProcedure";
|
|
import { router, importHandler } from "../../../trpc";
|
|
import { ZListMembersSchema } from "./listPaginated.schema";
|
|
import { ZAdminLockUserAccountSchema } from "./lockUserAccount.schema";
|
|
import { ZAdminRemoveTwoFactor } from "./removeTwoFactor.schema";
|
|
import { ZAdminPasswordResetSchema } from "./sendPasswordReset.schema";
|
|
import { ZSetSMSLockState } from "./setSMSLockState.schema";
|
|
|
|
const NAMESPACE = "admin";
|
|
|
|
const namespaced = (s: string) => `${NAMESPACE}.${s}`;
|
|
|
|
export const adminRouter = router({
|
|
listPaginated: authedAdminProcedure.input(ZListMembersSchema).query(async (opts) => {
|
|
const handler = await importHandler(namespaced("listPaginated"), () => import("./listPaginated.handler"));
|
|
return handler(opts);
|
|
}),
|
|
sendPasswordReset: authedAdminProcedure.input(ZAdminPasswordResetSchema).mutation(async (opts) => {
|
|
const handler = await importHandler(
|
|
namespaced("sendPasswordReset"),
|
|
() => import("./sendPasswordReset.handler")
|
|
);
|
|
return handler(opts);
|
|
}),
|
|
lockUserAccount: authedAdminProcedure.input(ZAdminLockUserAccountSchema).mutation(async (opts) => {
|
|
const handler = await importHandler(
|
|
namespaced("lockUserAccount"),
|
|
() => import("./lockUserAccount.handler")
|
|
);
|
|
return handler(opts);
|
|
}),
|
|
toggleFeatureFlag: authedAdminProcedure
|
|
.input(z.object({ slug: z.string(), enabled: z.boolean() }))
|
|
.mutation(({ ctx, input }) => {
|
|
const { prisma, user } = ctx;
|
|
const { slug, enabled } = input;
|
|
return prisma.feature.update({
|
|
where: { slug },
|
|
data: { enabled, updatedBy: user.id },
|
|
});
|
|
}),
|
|
removeTwoFactor: authedAdminProcedure.input(ZAdminRemoveTwoFactor).mutation(async (opts) => {
|
|
const handler = await importHandler(
|
|
namespaced("removeTwoFactor"),
|
|
() => import("./removeTwoFactor.handler")
|
|
);
|
|
return handler(opts);
|
|
}),
|
|
getSMSLockStateTeamsUsers: authedAdminProcedure.query(async (opts) => {
|
|
const handler = await importHandler(
|
|
namespaced("getSMSLockStateTeamsUsers"),
|
|
() => import("./getSMSLockStateTeamsUsers.handler")
|
|
);
|
|
return handler(opts);
|
|
}),
|
|
setSMSLockState: authedAdminProcedure.input(ZSetSMSLockState).mutation(async (opts) => {
|
|
const handler = await importHandler(
|
|
namespaced("setSMSLockState"),
|
|
() => import("./setSMSLockState.handler")
|
|
);
|
|
return handler(opts);
|
|
}),
|
|
});
|