The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/packages/rocketchat-lib/server/methods/removeOAuthService.js

33 lines
1.6 KiB

Meteor.methods({
removeOAuthService(name) {
check(name, String);
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'removeOAuthService' });
}
if (RocketChat.authz.hasPermission(Meteor.userId(), 'add-oauth-service') !== true) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'removeOAuthService' });
}
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}-scope`);
RocketChat.settings.removeById(`Accounts_OAuth_Custom-${name}-token_sent_via`);
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`);
RocketChat.settings.removeById(`Accounts_OAuth_Custom-${name}-login_style`);
RocketChat.settings.removeById(`Accounts_OAuth_Custom-${name}-username_field`);
RocketChat.settings.removeById(`Accounts_OAuth_Custom-${name}-merge_users`);
}
});