mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01: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) {
|
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
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user