Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Option to remove users from RocketChat if not found in Crowd #17619

Merged
merged 4 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/crowd/server/crowd.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { _setRealName } from '../../lib';
import { Users } from '../../models';
import { settings } from '../../settings';
import { hasRole } from '../../authorization';
import { deleteUser } from '../../lib/server/functions';

const logger = new Logger('CROWD', {});

Expand Down Expand Up @@ -203,6 +204,13 @@ export class CROWD {
const response = self.crowdClient.searchSync('user', `email=" ${ email } "`);
if (!response || response.users.length === 0) {
logger.warn('Could not find user in CROWD with username or email:', crowd_username, email);
if (settings.get('CROWD_Remove_Orphaned_Users') === true) {
logger.info('Removing user:', crowd_username);
Meteor.defer(function() {
deleteUser(user._id);
logger.info('User removed:', crowd_username);
});
}
return;
}
crowd_username = response.users[0].name;
Expand Down
1 change: 1 addition & 0 deletions app/crowd/server/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Meteor.startup(function() {
this.add('CROWD_APP_PASSWORD', '', { type: 'password', enableQuery, i18nLabel: 'Password', secret: true });
this.add('CROWD_Sync_User_Data', false, { type: 'boolean', enableQuery, i18nLabel: 'Sync_Users' });
this.add('CROWD_Sync_Interval', 'Every 60 mins', { type: 'string', enableQuery: enableSyncQuery, i18nLabel: 'Sync_Interval', i18nDescription: 'Crowd_sync_interval_Description' });
this.add('CROWD_Remove_Orphaned_Users', false, { type: 'boolean', public: true, i18nLabel: 'Crowd_Remove_Orphaned_Users' });
this.add('CROWD_Clean_Usernames', true, { type: 'boolean', enableQuery, i18nLabel: 'Clean_Usernames', i18nDescription: 'Crowd_clean_usernames_Description' });
this.add('CROWD_Allow_Custom_Username', true, { type: 'boolean', i18nLabel: 'CROWD_Allow_Custom_Username' });
this.add('CROWD_Test_Connection', 'crowd_test_connection', { type: 'action', actionText: 'Test_Connection', i18nLabel: 'Test_Connection' });
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@
"CRM_Integration": "CRM Integration",
"CROWD_Allow_Custom_Username": "Allow custom username in Rocket.Chat",
"CROWD_Reject_Unauthorized": "Reject Unauthorized",
"Crowd_Remove_Orphaned_Users": "Remove Orphaned Users",
"Crowd_sync_interval_Description": "The interval between synchronizations. Example `every 24 hours` or `on the first day of the week`, more examples at [Cron Text Parser](http://bunkat.github.io/later/parsers.html#text)",
"Current_Chats": "Current Chats",
"Current_File": "Current File",
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-i18n/i18n/it.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@
"Created_at_s_by_s_triggered_by_s": "Creato alle <strong>%s</strong> da <strong>%s</strong> scatenato da <strong>%s</strong>",
"CRM_Integration": "Integrazione CRM",
"CROWD_Reject_Unauthorized": "Rifiuta non autorizzati",
"Crowd_Remove_Orphaned_Users": "Rimuovi utenti orfani",
"Crowd_sync_interval_Description": "L'intervallo tra le sincronizzazioni. Esempio \"ogni 24 ore\" o \"il primo giorno della settimana\", altri esempi su [Cron Text Parser] (http://bunkat.github.io/later/parsers.html#text)",
"Current_Chats": "Chat attuali",
"Current_Status": "Stato attuale",
Expand Down Expand Up @@ -2890,4 +2891,4 @@
"Your_push_was_sent_to_s_devices": "La tua richiesta è stata inviata ai %s dispositivi.",
"Your_server_link": "Il tuo collegamento al server",
"Your_workspace_is_ready": "Il tuo spazio di lavoro è pronto per l'uso 🎉"
}
}
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@
"CRM_Integration": "Integração de CRM",
"CROWD_Allow_Custom_Username": "Permitir nome de usuário personalizado no Rocket.Chat",
"CROWD_Reject_Unauthorized": "Rejeitar não autorizado",
"Crowd_Remove_Orphaned_Users": "Remover usuários órfãos",
"Crowd_sync_interval_Description": "O intervalo entre as sincronizações. Exemplo de \"todas as 24 horas\" ou \"no primeiro dia da semana\", mais exemplos em [Cron Text Parser] (http://bunkat.github.io/later/parsers.html#text)",
"Current_Chats": "Bate-papos atuais",
"Current_File": "Arquivo atual",
Expand Down