Skip to content

Commit

Permalink
chore!: Improve permissions check on licenses endpoints (#32354)
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusbsilva137 authored and ggazzo committed Sep 27, 2024
1 parent cba6c7e commit 3fb0302
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions apps/meteor/ee/server/api/licenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,13 @@ API.v1.addRoute(

API.v1.addRoute(
'licenses.add',
{ authRequired: true },
{ authRequired: true, permissionsRequired: ['edit-privileged-setting'] },
{
async post() {
check(this.bodyParams, {
license: String,
});

if (!(await hasPermissionAsync(this.userId, 'edit-privileged-setting'))) {
return API.v1.unauthorized();
}

const { license } = this.bodyParams;
if (!(await License.validateFormat(license))) {
return API.v1.failure('Invalid license');
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/tests/end-to-end/api/licenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('licenses', () => {
.expect(403)
.expect((res) => {
expect(res.body).to.have.property('success', false);
expect(res.body).to.have.property('error', 'unauthorized');
expect(res.body).to.have.property('error', 'User does not have the permissions required for this action [error-unauthorized]');
})
.end(done);
});
Expand Down

0 comments on commit 3fb0302

Please sign in to comment.