Implemented document checks into the member.ts controller
This commit is contained in:
parent
fc96aaa251
commit
efdd4ab336
@ -5,6 +5,7 @@ import { IMember, Member } from "@models/Member";
|
||||
import { Account } from "@models/Account";
|
||||
import { sendMail } from "@utils/email";
|
||||
import { getSimpleAccountObjectById } from "@controller/account";
|
||||
import { planLimits } from "../limits/plans";
|
||||
|
||||
export const sendInvitationMail = async (email: string, username: string, projectName: string) => {
|
||||
sendMail({
|
||||
@ -38,6 +39,9 @@ export const inviteMember = async (userId: string, projectId: string, configurat
|
||||
allowInvites: true,
|
||||
}, { email: encryptClearField(configuration.user), verified: true, allowInvites: true }]);
|
||||
|
||||
const count = await Member.countDocuments({ projectId: encryptClearField(String(access._id)) });
|
||||
if (count >= planLimits[access.plan].MEMBERS) return { code: 95, message: "You have exceeded the member limit" };
|
||||
|
||||
if (account === null) return { code: 1002, message: "The provided account does not exist or disabled invites" };
|
||||
if (String(account._id) === userId) return { code: 1005, message: "You cannot invite yourself" };
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user