diff --git a/packages/rocketchat-lib/package.js b/packages/rocketchat-lib/package.js index d7b956828b9..24c6d5fdc85 100644 --- a/packages/rocketchat-lib/package.js +++ b/packages/rocketchat-lib/package.js @@ -48,13 +48,15 @@ Package.onUse(function(api) { api.addFiles('server/functions/setUsername.coffee', 'server'); // SERVER METHODS + api.addFiles('server/methods/addOAuthService.coffee', 'server'); api.addFiles('server/methods/joinDefaultChannels.coffee', 'server'); + api.addFiles('server/methods/removeOAuthService.coffee', 'server'); api.addFiles('server/methods/robotMethods.coffee', 'server'); + api.addFiles('server/methods/saveSetting.coffee', 'server'); api.addFiles('server/methods/sendInvitationEmail.coffee', 'server'); api.addFiles('server/methods/sendMessage.coffee', 'server'); api.addFiles('server/methods/setAdminStatus.coffee', 'server'); api.addFiles('server/methods/setRealName.coffee', 'server'); - api.addFiles('server/methods/saveSetting.coffee', 'server'); api.addFiles('server/methods/setUsername.coffee', 'server'); api.addFiles('server/methods/updateUser.coffee', 'server'); @@ -63,10 +65,8 @@ Package.onUse(function(api) { // Settings api.addFiles('settings/lib/onLoadSettings.coffee'); - api.addFiles('settings/server/startup.coffee', 'server'); api.addFiles('settings/server/updateServices.coffee', 'server'); - api.addFiles('settings/server/addOAuthService.coffee', 'server'); // CLIENT LIB api.addFiles('client/lib/openRoom.coffee', 'client'); diff --git a/packages/rocketchat-lib/settings/server/addOAuthService.coffee b/packages/rocketchat-lib/server/methods/addOAuthService.coffee similarity index 68% rename from packages/rocketchat-lib/settings/server/addOAuthService.coffee rename to packages/rocketchat-lib/server/methods/addOAuthService.coffee index 9ce3c9ca140..bf10e8f8907 100644 --- a/packages/rocketchat-lib/settings/server/addOAuthService.coffee +++ b/packages/rocketchat-lib/server/methods/addOAuthService.coffee @@ -20,25 +20,3 @@ Meteor.methods RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_button_label_text" , '' , { type: 'string' , group: 'Accounts', section: "Custom OAuth: #{name}", i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Text'} RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_button_label_color", '#FFFFFF' , { type: 'string' , group: 'Accounts', section: "Custom OAuth: #{name}", i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Color'} RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_button_color" , '#13679A' , { type: 'string' , group: 'Accounts', section: "Custom OAuth: #{name}", i18nLabel: 'Accounts_OAuth_Custom_Button_Color'} - - removeOAuthService: (name) -> - if not Meteor.userId() - throw new Meteor.Error('invalid-user', "[methods] addOAuthService -> Invalid user") - - console.log '[methods] addOAuthService -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments - - unless RocketChat.authz.hasPermission( Meteor.userId(), 'add-oauth-service') is true - throw new Meteor.Error 'not-authorized', '[methods] addOAuthService -> Not authorized' - - name = name.toLowerCase().replace(/[^a-z0-9]/g, '') - name = s.capitalize(name) - RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}" - RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_url" - RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_token_path" - RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_identity_path" - RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_authorize_path" - RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_id" - RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_secret" - RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_button_label_text" - RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_button_label_color" - RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_button_color" diff --git a/packages/rocketchat-lib/server/methods/removeOAuthService.coffee b/packages/rocketchat-lib/server/methods/removeOAuthService.coffee new file mode 100644 index 00000000000..60d94fef7ee --- /dev/null +++ b/packages/rocketchat-lib/server/methods/removeOAuthService.coffee @@ -0,0 +1,22 @@ +Meteor.methods + removeOAuthService: (name) -> + if not Meteor.userId() + throw new Meteor.Error('invalid-user', "[methods] addOAuthService -> Invalid user") + + console.log '[methods] addOAuthService -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments + + unless RocketChat.authz.hasPermission( Meteor.userId(), 'add-oauth-service') is true + throw new Meteor.Error 'not-authorized', '[methods] addOAuthService -> Not authorized' + + name = name.toLowerCase().replace(/[^a-z0-9]/g, '') + name = s.capitalize(name) + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_url" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_token_path" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_identity_path" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_authorize_path" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_id" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_secret" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_button_label_text" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_button_label_color" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_button_color"