feat: Add custom OAuth setting to allow merging users to others from distinct services (#28783)
* Merge OAuth users with existing users from distinct services when setting is enabled * Add changesets * Fix changesets * Apply requested changes --------- Co-authored-by: Diego Sampaio <chinello@gmail.com> Co-authored-by: Rafael Tapia <rafael.tapia@rocket.chat> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Gabriel Casals <83978645+casalsgh@users.noreply.github.com>pull/29606/head^2
parent
eecd9fc99a
commit
74aa677088
@ -0,0 +1,6 @@ |
||||
--- |
||||
"@rocket.chat/meteor": minor |
||||
"@rocket.chat/rest-typings": minor |
||||
--- |
||||
|
||||
feat: Add custom OAuth setting to allow merging users to others from distinct services |
||||
@ -0,0 +1,27 @@ |
||||
import { Settings } from '@rocket.chat/models'; |
||||
|
||||
import { settingsRegistry } from '../../../app/settings/server'; |
||||
import { addMigration } from '../../lib/migrations'; |
||||
|
||||
addMigration({ |
||||
version: 300, |
||||
async up() { |
||||
const customOauthServices = await Settings.find({ _id: /Accounts_OAuth_Custom-[^-]+$/ }, { projection: { _id: 1 } }).toArray(); |
||||
const serviceNames = customOauthServices.map(({ _id }) => _id.replace('Accounts_OAuth_Custom-', '')); |
||||
|
||||
for await (const serviceName of serviceNames) { |
||||
await settingsRegistry.add(`Accounts_OAuth_Custom-${serviceName}-merge_users_distinct_services`, false, { |
||||
type: 'boolean', |
||||
group: 'OAuth', |
||||
section: `Custom OAuth: ${serviceName}`, |
||||
i18nLabel: 'Accounts_OAuth_Custom_Merge_Users_Distinct_Services', |
||||
i18nDescription: 'Accounts_OAuth_Custom_Merge_Users_Distinct_Services_Description', |
||||
enableQuery: { |
||||
_id: `Accounts_OAuth_Custom-${serviceName}-merge_users`, |
||||
value: true, |
||||
}, |
||||
persistent: true, |
||||
}); |
||||
} |
||||
}, |
||||
}); |
||||
Loading…
Reference in new issue