mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-11 16:28:37 +01:00
new selfhosted version
This commit is contained in:
29
dashboard/server/api/members/edit.post.ts
Normal file
29
dashboard/server/api/members/edit.post.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { TeamMemberModel } from "~/shared/schema/TeamMemberSchema";
|
||||
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
const ctx = await getRequestContext(event, 'pid');
|
||||
|
||||
const { user_id, project } = ctx;
|
||||
|
||||
const body = await readBody(event);
|
||||
const { member_id, webAnalytics, events, ai, domains } = body;
|
||||
|
||||
const isOwner = user_id === project.owner.toString();
|
||||
if (!isOwner) throw createError({ status: 403, message: 'Only owner can change roles' })
|
||||
|
||||
if (!member_id) return setResponseStatus(event, 400, 'member_id is required');
|
||||
|
||||
const edited = await TeamMemberModel.updateOne({ _id: member_id }, {
|
||||
permission: {
|
||||
webAnalytics,
|
||||
events,
|
||||
ai,
|
||||
domains
|
||||
}
|
||||
});
|
||||
|
||||
return { ok: edited.modifiedCount == 1 }
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user