refactor: remove add oauth service meteor call (#35921)

pull/35949/head
Marcos Spessatto Defendi 8 months ago committed by GitHub
parent 079dcda1a8
commit 5861af4727
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      apps/meteor/app/api/server/v1/settings.ts
  2. 20
      apps/meteor/app/lib/server/methods/addOAuthService.ts

@ -22,6 +22,7 @@ import { updateAuditedByUser } from '../../../../server/settings/lib/auditedSett
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { disableCustomScripts } from '../../../lib/server/functions/disableCustomScripts';
import { notifyOnSettingChanged, notifyOnSettingChangedById } from '../../../lib/server/lib/notifyListener';
import { addOAuthServiceMethod } from '../../../lib/server/methods/addOAuthService';
import { SettingsEvents, settings } from '../../../settings/server';
import { setValue } from '../../../settings/server/raw';
import { API } from '../api';
@ -123,7 +124,7 @@ API.v1.addRoute(
throw new Meteor.Error('error-name-param-not-provided', 'The parameter "name" is required');
}
await Meteor.callAsync('addOAuthService', this.bodyParams.name, this.userId);
await addOAuthServiceMethod(this.userId, this.bodyParams.name);
return API.v1.success();
},

@ -12,6 +12,17 @@ declare module '@rocket.chat/ddp-client' {
}
}
export const addOAuthServiceMethod = async (userId: string, name: string): Promise<void> => {
if ((await hasPermissionAsync(userId, 'add-oauth-service')) !== true) {
throw new Meteor.Error('error-action-not-allowed', 'Adding OAuth Services is not allowed', {
method: 'addOAuthService',
action: 'Adding_OAuth_Services',
});
}
await addOAuthService(name);
};
Meteor.methods<ServerMethods>({
async addOAuthService(name) {
check(name, String);
@ -22,13 +33,6 @@ Meteor.methods<ServerMethods>({
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'addOAuthService' });
}
if ((await hasPermissionAsync(userId, 'add-oauth-service')) !== true) {
throw new Meteor.Error('error-action-not-allowed', 'Adding OAuth Services is not allowed', {
method: 'addOAuthService',
action: 'Adding_OAuth_Services',
});
}
await addOAuthService(name);
return addOAuthServiceMethod(userId, name);
},
});

Loading…
Cancel
Save