{"record":{"id":"21ce95cf21a24422","repo":"RocketChat/Rocket.Chat","slug":"error-not-authorized-21ce95","errorCode":"error-not-authorized","errorMessage":"Not authorized","messagePattern":"Not authorized","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/bridges/slack/removeChannelLinks.ts","lineNumber":25,"sourceCode":"\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tremoveSlackBridgeChannelLinks(): { message: string; params: unknown[] };\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync removeSlackBridgeChannelLinks() {\n\t\tconst user = await Meteor.userAsync();\n\t\tif (!user) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'removeSlackBridgeChannelLinks',\n\t\t\t});\n\t\t}\n\n\t\tif (!(await hasPermissionAsync(user, 'remove-slackbridge-links'))) {\n\t\t\tthrow new Meteor.Error('error-not-authorized', 'Not authorized', {\n\t\t\t\tmethod: 'removeSlackBridgeChannelLinks',\n\t\t\t});\n\t\t}\n\n\t\tif (settings.get('SlackBridge_Enabled') !== true) {\n\t\t\tthrow new Meteor.Error('SlackBridge_disabled');\n\t\t}\n\n\t\tawait Rooms.unsetAllImportIds();\n\n\t\treturn {\n\t\t\tmessage: 'Slackbridge_channel_links_removed_successfully',\n\t\t\tparams: [],\n\t\t};\n\t},\n});\n","sourceCodeStart":7,"sourceCodeEnd":42,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/bridges/slack/removeChannelLinks.ts#L7-L42","documentation":"Thrown by removeSlackBridgeChannelLinks when the caller is authenticated but lacks the 'remove-slackbridge-links' permission. This is a dedicated permission for the destructive operation of stripping all importIds (SlackBridge channel links) from rooms.","triggerScenarios":"A logged-in admin/operator without remove-slackbridge-links calls Meteor.call('removeSlackBridgeChannelLinks').","commonSituations":"Role created to manage SlackBridge imports but not granted the removal permission. Default admin lost the permission after a permissions reset.","solutions":["Grant 'remove-slackbridge-links' to the calling role in the permissions admin.","Gate the UI control on the same permission so unauthorized users never see it.","Confirm the operation is truly wanted - it is destructive (unsets all rooms' importIds)."],"exampleFix":"// before\nMeteor.call('removeSlackBridgeChannelLinks') // lacks permission\n\n// after\n// admin: assign remove-slackbridge-links to the role, then\nMeteor.call('removeSlackBridgeChannelLinks')","handlingStrategy":"validation","validationCode":"const canRemove = await hasPermission('remove-slackbridge-links');\nif (!canRemove) throw new ClientError('forbidden','remove-slackbridge-links required');","typeGuard":"function canRemoveSlackLinks(perms) { return Array.isArray(perms) && perms.includes('remove-slackbridge-links'); }","tryCatchPattern":"try { Meteor.call('removeSlackBridgeChannelLinks'); }\ncatch (e) {\n  if (e?.error === 'error-not-authorized') { surface('remove-slackbridge-links permission missing'); return; }\n  throw e;\n}","preventionTips":["Grant remove-slackbridge-links only to roles that should perform this destructive action.","Hide the control for roles lacking the permission.","Confirm intent - the operation clears all rooms' importIds."],"tags":["meteor","methods","slack","bridge","permissions","authorization"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}