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 Jun 11, 2024
1 parent dafd750 commit ddd3214
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 @@ -40,17 +40,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/20-licenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('licenses', function () {
.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 ddd3214

Please sign in to comment.