Migrate transferOwnership to zod

GitOrigin-RevId: 406886fcf721091e084ed76ca59ef2ded76ab9d2
This commit is contained in:
Eric Mc Sween
2025-09-23 08:06:26 +00:00
committed by Copybot
parent c0bb6bd6bc
commit 2b13dabf6f
2 changed files with 12 additions and 10 deletions
@@ -131,10 +131,20 @@ async function setCollaboratorInfo(req, res, next) {
} }
} }
const transferOwnershipSchema = z.object({
params: z.object({
Project_id: zz.objectId(),
}),
body: z.object({
user_id: zz.objectId(),
}),
})
async function transferOwnership(req, res, next) { async function transferOwnership(req, res, next) {
const sessionUser = SessionManager.getSessionUser(req.session) const sessionUser = SessionManager.getSessionUser(req.session)
const projectId = req.params.Project_id const { params, body } = validateReq(req, transferOwnershipSchema)
const toUserId = req.body.user_id const projectId = params.Project_id
const toUserId = body.user_id
try { try {
await OwnershipTransferHandler.promises.transferOwnership( await OwnershipTransferHandler.promises.transferOwnership(
projectId, projectId,
@@ -65,14 +65,6 @@ export default {
webRouter.post( webRouter.post(
'/project/:Project_id/transfer-ownership', '/project/:Project_id/transfer-ownership',
AuthenticationController.requireLogin(), AuthenticationController.requireLogin(),
validate({
params: Joi.object({
Project_id: Joi.objectId(),
}),
body: Joi.object({
user_id: Joi.objectId(),
}),
}),
AuthorizationMiddleware.ensureUserCanAdminProject, AuthorizationMiddleware.ensureUserCanAdminProject,
CollaboratorsController.transferOwnership CollaboratorsController.transferOwnership
) )