mirror of
https://github.com/outline/outline.git
synced 2026-12-01 01:14:11 +03:00
fix: allow admins to view token
This commit is contained in:
1 parent
2402cb4394
commit
2afcccabe1
3 files changed
+20
-6
No files matched your search
@@ -28,7 +28,6 @@ export enum UserCreatableIntegrationService {
|
||||
{
|
||||
model: IntegrationAuthentication,
|
||||
as: "authentication",
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { Integration } from "@server/models";
|
||||
|
||||
export default function presentIntegration(integration: Integration) {
|
||||
type Options = {
|
||||
includeToken?: boolean;
|
||||
};
|
||||
|
||||
export default function presentIntegration(
|
||||
integration: Integration,
|
||||
options?: Options
|
||||
) {
|
||||
return {
|
||||
id: integration.id,
|
||||
type: integration.type,
|
||||
@@ -8,6 +15,10 @@ export default function presentIntegration(integration: Integration) {
|
||||
teamId: integration.teamId,
|
||||
collectionId: integration.collectionId,
|
||||
authenticationId: integration.authenticationId,
|
||||
token:
|
||||
options && options.includeToken && integration.authentication
|
||||
? integration.authentication.token
|
||||
: undefined,
|
||||
service: integration.service,
|
||||
events: integration.events,
|
||||
settings: integration.settings,
|
||||
|
||||
@@ -35,7 +35,9 @@ router.post(
|
||||
};
|
||||
}
|
||||
|
||||
const integrations = await Integration.findAll({
|
||||
const integrations = await Integration.scope([
|
||||
"withAuthentication",
|
||||
]).findAll({
|
||||
where,
|
||||
order: [[sort, direction]],
|
||||
offset: ctx.state.pagination.offset,
|
||||
@@ -44,7 +46,9 @@ router.post(
|
||||
|
||||
ctx.body = {
|
||||
pagination: ctx.state.pagination,
|
||||
data: integrations.map(presentIntegration),
|
||||
data: integrations.map((integration) =>
|
||||
presentIntegration(integration, { includeToken: user.isAdmin })
|
||||
),
|
||||
};
|
||||
}
|
||||
);
|
||||
@@ -90,7 +94,7 @@ router.post(
|
||||
}
|
||||
|
||||
ctx.body = {
|
||||
data: presentIntegration(integration),
|
||||
data: presentIntegration(integration, { includeToken: user.isAdmin }),
|
||||
};
|
||||
}
|
||||
);
|
||||
@@ -157,7 +161,7 @@ router.post(
|
||||
await integration.save({ transaction });
|
||||
|
||||
ctx.body = {
|
||||
data: presentIntegration(integration),
|
||||
data: presentIntegration(integration, { includeToken: user.isAdmin }),
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user