mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 13:49:00 +02:00
Migrate transferOwnership to zod
GitOrigin-RevId: 406886fcf721091e084ed76ca59ef2ded76ab9d2
This commit is contained in:
@@ -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) {
|
||||
const sessionUser = SessionManager.getSessionUser(req.session)
|
||||
const projectId = req.params.Project_id
|
||||
const toUserId = req.body.user_id
|
||||
const { params, body } = validateReq(req, transferOwnershipSchema)
|
||||
const projectId = params.Project_id
|
||||
const toUserId = body.user_id
|
||||
try {
|
||||
await OwnershipTransferHandler.promises.transferOwnership(
|
||||
projectId,
|
||||
|
||||
@@ -65,14 +65,6 @@ export default {
|
||||
webRouter.post(
|
||||
'/project/:Project_id/transfer-ownership',
|
||||
AuthenticationController.requireLogin(),
|
||||
validate({
|
||||
params: Joi.object({
|
||||
Project_id: Joi.objectId(),
|
||||
}),
|
||||
body: Joi.object({
|
||||
user_id: Joi.objectId(),
|
||||
}),
|
||||
}),
|
||||
AuthorizationMiddleware.ensureUserCanAdminProject,
|
||||
CollaboratorsController.transferOwnership
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user