mirror of
https://github.com/outline/outline.git
synced 2026-11-28 16:19:46 +03:00
fix: Consistent order of checks in accessRequests.approve (#14232)
This commit is contained in:
1 parent
0720b83f9f
commit
8bbd371db6
2 files changed
+33
-4
No files matched your search
@@ -465,6 +465,35 @@ describe("#accessRequests.approve", () => {
|
||||
|
||||
expect(res.status).toEqual(400);
|
||||
});
|
||||
|
||||
it("should not reveal status of responded requests to non-managers", async () => {
|
||||
const team = await buildTeam();
|
||||
const requester = await buildUser({ teamId: team.id });
|
||||
const admin = await buildAdmin({ teamId: team.id });
|
||||
const nonManager = await buildUser();
|
||||
const document = await buildDocument({
|
||||
createdById: admin.id,
|
||||
teamId: team.id,
|
||||
});
|
||||
|
||||
const accessRequest = await AccessRequest.create({
|
||||
documentId: document.id,
|
||||
userId: requester.id,
|
||||
teamId: team.id,
|
||||
status: AccessRequestStatus.Approved,
|
||||
responderId: admin.id,
|
||||
respondedAt: new Date(),
|
||||
});
|
||||
|
||||
const res = await server.post("/api/accessRequests.approve", nonManager, {
|
||||
body: {
|
||||
id: accessRequest.id,
|
||||
permission: DocumentPermission.ReadWrite,
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.status).toEqual(403);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#accessRequests.dismiss", () => {
|
||||
|
||||
@@ -102,10 +102,6 @@ router.post(
|
||||
lock: { level: transaction.LOCK.UPDATE, of: AccessRequest },
|
||||
});
|
||||
|
||||
if (accessRequest.status !== AccessRequestStatus.Pending) {
|
||||
throw InvalidRequestError("Access request has already been responded to");
|
||||
}
|
||||
|
||||
const document = await Document.findByPk(accessRequest.documentId, {
|
||||
userId: user.id,
|
||||
transaction,
|
||||
@@ -114,6 +110,10 @@ router.post(
|
||||
authorize(user, "manageUsers", document);
|
||||
authorize(user, "read", accessRequest.user);
|
||||
|
||||
if (accessRequest.status !== AccessRequestStatus.Pending) {
|
||||
throw InvalidRequestError("Access request has already been responded to");
|
||||
}
|
||||
|
||||
const membership = await UserMembership.findOne({
|
||||
where: {
|
||||
userId: accessRequest.userId,
|
||||
|
||||
Reference in new issue
Block a user