From 2773c049535a17c2ec862a15887aee44d52063a8 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 27 Apr 2022 16:05:27 +0100 Subject: [PATCH] Fix for #5522 - making sure that app roles aren't removed when an app is unpublished. --- packages/server/src/api/controllers/application.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/application.ts b/packages/server/src/api/controllers/application.ts index 4e6d37765f..aa76dd403c 100644 --- a/packages/server/src/api/controllers/application.ts +++ b/packages/server/src/api/controllers/application.ts @@ -406,11 +406,14 @@ const destroyApp = async (ctx: any) => { if (!env.isTest() && !isUnpublish) { await deleteApp(appId) } + // automations only in production if (isUnpublish) { await cleanupAutomations(appId) } - // make sure the app/role doesn't stick around after the app has been deleted - await removeAppFromUserRoles(ctx, appId) + // remove app role when the dev app is deleted (no trace of app anymore) + else { + await removeAppFromUserRoles(ctx, appId) + } await appCache.invalidateAppMetadata(appId) return result }