Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: organisaiton delete

Blue Mouse3864677c86d1
diff --git a/backend/apps/cloud/src/organisation/organisation.controller.ts b/backend/apps/cloud/src/organisation/organisation.controller.ts
index 65c03ff92..4dd13dbae 100644
--- a/backend/apps/cloud/src/organisation/organisation.controller.ts
+++ b/backend/apps/cloud/src/organisation/organisation.controller.ts
@@ -40,6 +40,8 @@ import { AppLoggerService } from '../logger/logger.service'
import { LetterTemplate } from '../mailer/letter'
import { Auth } from '../auth/decorators'
import { Pagination } from '../common/pagination'
+import { ProjectService } from '../project/project.service'
+import { Project } from '../project/entity'
const ORGANISATION_INVITE_EXPIRE = 7 * 24 // 7 days in hours
const { PRODUCTION_ORIGIN, isDevelopment } = process.env
@@ -52,6 +54,7 @@ export class OrganisationController {
private readonly mailerService: MailerService,
private readonly actionTokensService: ActionTokensService,
private readonly logger: AppLoggerService,
+ private readonly projectService: ProjectService,
) {}
@ApiBearerAuth()
@@ -378,6 +381,9 @@ export class OrganisationController {
}
try {
+ await this.projectService.update({ organisation: { id: orgId } }, {
+ organisation: null,
+ } as Project)
await this.organisationService.deleteMemberships({
organisation: { id: orgId },
})
diff --git a/backend/apps/cloud/src/organisation/organisation.module.ts b/backend/apps/cloud/src/organisation/organisation.module.ts
index 8bcbd34f2..a67f76ce7 100644
--- a/backend/apps/cloud/src/organisation/organisation.module.ts
+++ b/backend/apps/cloud/src/organisation/organisation.module.ts
@@ -8,11 +8,13 @@ import { UserModule } from '../user/user.module'
import { MailerModule } from '../mailer/mailer.module'
import { ActionTokensModule } from '../action-tokens/action-tokens.module'
import { AppLoggerModule } from '../logger/logger.module'
+import { ProjectModule } from '../project/project.module'
@Module({
imports: [
TypeOrmModule.forFeature([Organisation, OrganisationMember]),
forwardRef(() => UserModule),
+ forwardRef(() => ProjectModule),
MailerModule,
ActionTokensModule,
AppLoggerModule,
diff --git a/backend/apps/cloud/src/project/project.controller.ts b/backend/apps/cloud/src/project/project.controller.ts
index a54dbf165..9eb4fc8e2 100644
--- a/backend/apps/cloud/src/project/project.controller.ts
+++ b/backend/apps/cloud/src/project/project.controller.ts
@@ -713,7 +713,7 @@ export class ProjectController {
const secret = generateRandomString(CAPTCHA_SECRET_KEY_LENGTH)
// @ts-ignore
- await this.projectService.update(pid, { captchaSecretKey: secret })
+ await this.projectService.update({ id: pid }, { captchaSecretKey: secret })
await deleteProjectRedis(pid)
@@ -759,7 +759,7 @@ export class ProjectController {
project.isCaptchaEnabled = false
project.isCaptchaProject = false
- await this.projectService.update(id, project)
+ await this.projectService.update({ id }, project)
return 'CAPTCHA project deleted successfully'
} catch (e) {
@@ -1657,7 +1657,7 @@ export class ProjectController {
try {
if (project.isCaptchaProject) {
project.isAnalyticsProject = false
- await this.projectService.update(id, project)
+ await this.projectService.update({ id }, project)
} else {
await this.projectService.deleteMultipleShare(`project = "${id}"`)
await this.projectService.delete(id)
@@ -1843,7 +1843,7 @@ export class ProjectController {
}
// @ts-expect-error
- await this.projectService.update(id, _omit(project, ['share', 'admin']))
+ await this.projectService.update({ id }, _omit(project, ['share', 'admin']))
await deleteProjectRedis(id)
diff --git a/backend/apps/cloud/src/project/project.service.ts b/backend/apps/cloud/src/project/project.service.ts
index 601a26c9d..4fba8b7fc 100644
--- a/backend/apps/cloud/src/project/project.service.ts
+++ b/backend/apps/cloud/src/project/project.service.ts
@@ -546,8 +546,11 @@ export class ProjectService {
return this.projectsRepository.save(project)
}
- async update(id: string, projectDTO: ProjectDTO | Project) {
- return this.projectsRepository.update(id, projectDTO)
+ async update(
+ where: FindOptionsWhere<Project>,
+ projectDTO: ProjectDTO | Project,
+ ) {
+ return this.projectsRepository.update(where, projectDTO)
}
async delete(id: string) {
@@ -1701,7 +1704,7 @@ export class ProjectService {
throw new NotFoundException(`Project with ID ${projectId} not found`)
}
- return this.update(projectId, {
+ return this.update({ id: projectId }, {
organisation: {
id: organisationId,
} as Organisation,
@@ -1727,7 +1730,7 @@ export class ProjectService {
)
}
- return this.update(projectId, {
+ return this.update({ id: projectId }, {
organisation: null,
} as Project)
}
diff --git a/web/app/pages/Organisations/Settings/index.tsx b/web/app/pages/Organisations/Settings/index.tsx
index 1555e735f..939e955ed 100644
--- a/web/app/pages/Organisations/Settings/index.tsx
+++ b/web/app/pages/Organisations/Settings/index.tsx
@@ -109,6 +109,7 @@ const OrganisationSettings = () => {
if (isSaving) {
return
}
+
setIsSaving(true)
try {