mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
fix members
This commit is contained in:
@@ -8,6 +8,12 @@ import { LimitNotifyModel } from "@schema/broker/LimitNotifySchema";
|
||||
import { SessionModel } from "@schema/metrics/SessionSchema";
|
||||
import StripeService from "~/server/services/StripeService";
|
||||
import { UserModel } from "@schema/UserSchema";
|
||||
import { AddressBlacklistModel } from "~/shared/schema/shields/AddressBlacklistSchema";
|
||||
import { DomainWhitelistModel } from "~/shared/schema/shields/DomainWhitelistSchema";
|
||||
import { CountryBlacklistModel } from "~/shared/schema/shields/CountryBlacklistSchema";
|
||||
import { BotTrafficOptionModel } from "~/shared/schema/shields/BotTrafficOptionSchema";
|
||||
import { TeamMemberModel } from "~/shared/schema/TeamMemberSchema";
|
||||
import { PasswordModel } from "~/shared/schema/PasswordSchema";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
@@ -19,6 +25,11 @@ export default defineEventHandler(async event => {
|
||||
const premiumProjects = projects.filter(e => { return e.premium && e.premium_type != 0 }).length;
|
||||
if (premiumProjects > 0) return setResponseStatus(event, 400, 'Cannot delete an account with a premium project');
|
||||
|
||||
const membersDeletation = await TeamMemberModel.deleteMany({ user_id: userData.id });
|
||||
const membersEmailDeletation = await TeamMemberModel.deleteMany({ email: userData.user.email });
|
||||
|
||||
const passwordDeletation = await PasswordModel.deleteMany({ user_id: userData.id });
|
||||
|
||||
for (const project of projects) {
|
||||
const project_id = project._id;
|
||||
await StripeService.deleteCustomer(project.customer_id);
|
||||
@@ -28,9 +39,16 @@ export default defineEventHandler(async event => {
|
||||
const limitdeletation = await ProjectLimitModel.deleteMany({ project_id });
|
||||
const sessionsDeletation = await SessionModel.deleteMany({ project_id });
|
||||
const notifiesDeletation = await LimitNotifyModel.deleteMany({ project_id });
|
||||
const aiChatsDeletation = await AiChatModel.deleteMany({ project_id });
|
||||
|
||||
const userDeletation = await UserModel.deleteOne({ _id: userData.id });
|
||||
const aiChatsDeletation = await AiChatModel.deleteMany({ project_id });
|
||||
|
||||
//Shields
|
||||
const addressBlacklistDeletation = await AddressBlacklistModel.deleteMany({ project_id });
|
||||
const botTrafficOptionsDeletation = await BotTrafficOptionModel.deleteMany({ project_id });
|
||||
const countryBlacklistDeletation = await CountryBlacklistModel.deleteMany({ project_id });
|
||||
const domainWhitelistDeletation = await DomainWhitelistModel.deleteMany({ project_id });
|
||||
|
||||
|
||||
const userDeletation = await UserModel.deleteOne({ _id: userData.id });
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user