Skip to content

Commit

Permalink
✨ Allow moderators along with admins to toggle invite codes (#1928)
Browse files Browse the repository at this point in the history
* ✨ Allow moderators along with admins to toggle invite codes

* ✅ Adjust test to use triage token
  • Loading branch information
foysalit authored Dec 14, 2023
1 parent 2012796 commit 7d818b8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function (server: Server, ctx: AppContext) {
'Account invites are managed by the entryway service',
)
}
if (!auth.credentials.admin) {
if (!auth.credentials.moderator) {
throw new AuthRequiredError('Insufficient privileges')
}
const { account } = input.body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function (server: Server, ctx: AppContext) {
'Account invites are managed by the entryway service',
)
}
if (!auth.credentials.admin) {
if (!auth.credentials.moderator) {
throw new AuthRequiredError('Insufficient privileges')
}
const { codes = [], accounts = [] } = input.body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function (server: Server, ctx: AppContext) {
'Account invites are managed by the entryway service',
)
}
if (!auth.credentials.admin) {
if (!auth.credentials.moderator) {
throw new AuthRequiredError('Insufficient privileges')
}
const { account } = input.body
Expand Down
12 changes: 6 additions & 6 deletions packages/pds/tests/invites-admin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ describe('pds admin invite views', () => {
expect(aliceView.data.invites?.length).toBe(6)
})

it('does not allow non-admin moderators to disable invites.', async () => {
it('does not allow triage moderators to disable invites.', async () => {
const attemptDisableInvites =
agent.api.com.atproto.admin.disableInviteCodes(
{ codes: ['x'], accounts: [alice] },
{
encoding: 'application/json',
headers: network.pds.adminAuthHeaders('moderator'),
headers: network.pds.adminAuthHeaders('triage'),
},
)
await expect(attemptDisableInvites).rejects.toThrow(
Expand Down Expand Up @@ -255,12 +255,12 @@ describe('pds admin invite views', () => {
expect(res.every((row) => row.disabled === 1))
})

it('does not allow non-admin moderations to disable account invites', async () => {
it('does not allow triage moderators to disable account invites', async () => {
const attempt = agent.api.com.atproto.admin.disableAccountInvites(
{ account: alice },
{
encoding: 'application/json',
headers: network.pds.adminAuthHeaders('moderator'),
headers: network.pds.adminAuthHeaders('triage'),
},
)
await expect(attempt).rejects.toThrow('Insufficient privileges')
Expand All @@ -285,12 +285,12 @@ describe('pds admin invite views', () => {
expect(invRes.data.codes.length).toBeGreaterThan(0)
})

it('does not allow non-admin moderations to enable account invites', async () => {
it('does not allow triage moderators to enable account invites', async () => {
const attempt = agent.api.com.atproto.admin.enableAccountInvites(
{ account: alice },
{
encoding: 'application/json',
headers: network.pds.adminAuthHeaders('moderator'),
headers: network.pds.adminAuthHeaders('triage'),
},
)
await expect(attempt).rejects.toThrow('Insufficient privileges')
Expand Down

0 comments on commit 7d818b8

Please sign in to comment.