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/app/blockstack/server/settings.js

70 lines
1.9 KiB

import { Meteor } from 'meteor/meteor';
import { ServiceConfiguration } from 'meteor/service-configuration';
import { logger } from './logger';
import { settings, settingsRegistry } from '../../settings/server';
const defaults = {
enable: false,
loginStyle: 'redirect',
generateUsername: false,
manifestURI: Meteor.absoluteUrl('_blockstack/manifest'),
redirectURI: Meteor.absoluteUrl('_blockstack/validate'),
authDescription: 'Rocket.Chat login',
buttonLabelText: 'Blockstack',
buttonColor: '#271132',
buttonLabelColor: '#ffffff',
};
Meteor.startup(() => {
settingsRegistry.addGroup('Blockstack', function () {
this.add('Blockstack_Enable', defaults.enable, {
type: 'boolean',
i18nLabel: 'Enable',
});
this.add('Blockstack_Auth_Description', defaults.authDescription, {
type: 'string',
});
this.add('Blockstack_ButtonLabelText', defaults.buttonLabelText, {
type: 'string',
});
this.add('Blockstack_Generate_Username', defaults.generateUsername, {
type: 'boolean',
});
});
});
// Helper to return all Blockstack settings
const getSettings = () =>
Object.assign({}, defaults, {
enable: settings.get('Blockstack_Enable'),
authDescription: settings.get('Blockstack_Auth_Description'),
buttonLabelText: settings.get('Blockstack_ButtonLabelText'),
generateUsername: settings.get('Blockstack_Generate_Username'),
});
// Add settings to auth provider configs on startup
settings.watchMultiple(
['Blockstack_Enable', 'Blockstack_Auth_Description', 'Blockstack_ButtonLabelText', 'Blockstack_Generate_Username'],
() => {
const serviceConfig = getSettings();
if (!serviceConfig.enable) {
logger.debug('Blockstack not enabled', serviceConfig);
return ServiceConfiguration.configurations.remove({
service: 'blockstack',
});
}
ServiceConfiguration.configurations.upsert(
{
service: 'blockstack',
},
{
$set: serviceConfig,
},
);
logger.debug('Init Blockstack auth', serviceConfig);
},
);