Skip to content

Commit

Permalink
add migration to update default button colors
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-rajpal authored and ggazzo committed Oct 14, 2024
1 parent 178ab95 commit ab78098
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
10 changes: 7 additions & 3 deletions apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const configureSamlService = function (samlConfigs: Record<string, any>): IServi
};
};

export const loadSamlServiceProviders = async function (): Promise<void> {
export const loadSamlServiceProviders = async function (shouldNotify = true): Promise<void> {
const serviceName = 'saml';
const services = settings.getByRegexp(/^(SAML_Custom_)[a-z]+$/i);

Expand All @@ -121,7 +121,9 @@ export const loadSamlServiceProviders = async function (): Promise<void> {
const samlConfigs = getSamlConfigs(key);
SAMLUtils.log(key);
await LoginServiceConfiguration.createOrUpdateService(serviceName, samlConfigs);
void notifyOnLoginServiceConfigurationChangedByService(serviceName);
if (shouldNotify) {
void notifyOnLoginServiceConfigurationChangedByService(serviceName);
}
return configureSamlService(samlConfigs);
}

Expand All @@ -135,7 +137,9 @@ export const loadSamlServiceProviders = async function (): Promise<void> {
return false;
}

void notifyOnLoginServiceConfigurationChanged({ _id: service._id }, 'removed');
if (shouldNotify) {
void notifyOnLoginServiceConfigurationChanged({ _id: service._id }, 'removed');
}

return false;
}),
Expand Down
8 changes: 5 additions & 3 deletions apps/meteor/server/lib/oauth/updateOAuthServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { settings } from '../../../app/settings/server/cached';
import { logger } from './logger';

export async function updateOAuthServices(): Promise<void> {
export async function updateOAuthServices(shouldNotify = true): Promise<void> {
const services = settings.getByRegexp(/^(Accounts_OAuth_|Accounts_OAuth_Custom-)[a-z0-9_]+$/i);
const filteredServices = services.filter(([, value]) => typeof value === 'boolean');
for await (const [key, value] of filteredServices) {
Expand Down Expand Up @@ -117,12 +117,14 @@ export async function updateOAuthServices(): Promise<void> {
}

await LoginServiceConfiguration.createOrUpdateService(serviceKey, data);
void notifyOnLoginServiceConfigurationChangedByService(serviceKey);
if (shouldNotify) {
void notifyOnLoginServiceConfigurationChangedByService(serviceKey);
}
} else {
const service = await LoginServiceConfiguration.findOneByService(serviceName, { projection: { _id: 1 } });
if (service?._id) {
const { deletedCount } = await LoginServiceConfiguration.removeService(service._id);
if (deletedCount > 0) {
if (deletedCount > 0 && shouldNotify) {
void notifyOnLoginServiceConfigurationChanged({ _id: service._id }, 'removed');
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/server/lib/refreshLoginServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { loadSamlServiceProviders } from '../../app/meteor-accounts-saml/server/
import { updateCasServices } from './cas/updateCasService';
import { updateOAuthServices } from './oauth/updateOAuthServices';

export async function refreshLoginServices(): Promise<void> {
export async function refreshLoginServices(shouldNotify = true): Promise<void> {
await ServiceConfiguration.configurations.removeAsync({});

await Promise.allSettled([updateOAuthServices(), loadSamlServiceProviders(), updateCasServices()]);
await Promise.allSettled([updateOAuthServices(shouldNotify), loadSamlServiceProviders(shouldNotify), updateCasServices()]);
}
1 change: 1 addition & 0 deletions apps/meteor/server/startup/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ import './v307';
import './v308';
import './v309';
import './v310';
import './v311';

export * from './xrun';

0 comments on commit ab78098

Please sign in to comment.