add customUserId to add website of any user by admin

This commit is contained in:
Ankit Singh Tomar 2024-01-25 12:14:58 +05:30
parent 77fd98387c
commit 6d93b57d25

View file

@ -15,6 +15,7 @@ export interface WebsitesRequestBody {
name: string; name: string;
domain: string; domain: string;
shareId: string; shareId: string;
customUserId:string
} }
const schema = { const schema = {
@ -25,6 +26,7 @@ const schema = {
name: yup.string().max(100).required(), name: yup.string().max(100).required(),
domain: yup.string().max(500).required(), domain: yup.string().max(500).required(),
shareId: yup.string().max(50).nullable(), shareId: yup.string().max(50).nullable(),
customUserId: yup.string().max(50).nullable(),
}), }),
}; };
@ -53,7 +55,7 @@ export default async (
} }
if (req.method === 'POST') { if (req.method === 'POST') {
const { name, domain, shareId } = req.body; const { name, domain, shareId ,customUserId} = req.body;
if (!(await canCreateWebsite(req.auth))) { if (!(await canCreateWebsite(req.auth))) {
return unauthorized(res); return unauthorized(res);
@ -65,11 +67,11 @@ export default async (
domain, domain,
shareId, shareId,
}; };
data.userId = userId; data.userId = userId;
if(customUserId){
data.userId = customUserId;
}
const website = await createWebsite(data); const website = await createWebsite(data);
return ok(res, website); return ok(res, website);
} }