Skip to content

Commit

Permalink
fix: linter fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogarim committed May 15, 2024
1 parent 5b95b26 commit 715e34f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
13 changes: 8 additions & 5 deletions apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { LoginServiceConfiguration } from '@rocket.chat/models';
import { Meteor } from 'meteor/meteor';

import { SystemLogger } from '../../../../server/lib/logger/system';
import { notifyOnLoginServiceConfigurationChanged, notifyOnLoginServiceConfigurationChangedByService } from '../../../lib/server/lib/notifyListener';
import {
notifyOnLoginServiceConfigurationChanged,
notifyOnLoginServiceConfigurationChangedByService,
} from '../../../lib/server/lib/notifyListener';
import { settings, settingsRegistry } from '../../../settings/server';
import type { IServiceProviderOptions } from '../definition/IServiceProviderOptions';
import { SAMLUtils } from './Utils';
Expand Down Expand Up @@ -122,11 +125,11 @@ export const loadSamlServiceProviders = async function (): Promise<void> {
return configureSamlService(samlConfigs);
}

const { _id } = await LoginServiceConfiguration.findOneByService(serviceName, { projection: { _id: 1 } });
if (_id) {
const { deletedCount } = await LoginServiceConfiguration.removeService(_id);
const service = await LoginServiceConfiguration.findOneByService(serviceName, { projection: { _id: 1 } });
if (service?._id) {
const { deletedCount } = await LoginServiceConfiguration.removeService(service._id);
if (deletedCount === 1) {
void notifyOnLoginServiceConfigurationChanged({ _id }, 'removed');
void notifyOnLoginServiceConfigurationChanged({ _id: service._id }, 'removed');
}
}

Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/server/lib/oauth/updateOAuthServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ export async function updateOAuthServices(): Promise<void> {
await LoginServiceConfiguration.createOrUpdateService(serviceKey, data);
void notifyOnLoginServiceConfigurationChangedByService(serviceKey);
} else {
const { _id } = await LoginServiceConfiguration.findOneByService(serviceName, { projection: { _id: 1 } });
if (_id) {
const { deletedCount } = await LoginServiceConfiguration.removeService(_id);
const service = await LoginServiceConfiguration.findOneByService(serviceName, { projection: { _id: 1 } });
if (service?._id) {
const { deletedCount } = await LoginServiceConfiguration.removeService(service._id);
if (deletedCount === 1) {
void notifyOnLoginServiceConfigurationChanged({ _id }, 'removed');
void notifyOnLoginServiceConfigurationChanged({ _id: service._id }, 'removed');
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ export interface ILoginServiceConfigurationModel extends IBaseModel<LoginService
serviceData: Partial<LoginServiceConfiguration>,
): Promise<LoginServiceConfiguration['_id']>;
removeService(_id: LoginServiceConfiguration['_id']): Promise<DeleteResult>;
findOneByService(serviceName: LoginServiceConfiguration['service'], options?: FindOptions<ILoginServiceConfiguration>): Promise<LoginServiceConfiguration | null>;
findOneByService(
serviceName: LoginServiceConfiguration['service'],
options?: FindOptions<ILoginServiceConfiguration>,
): Promise<LoginServiceConfiguration | null>;
}

0 comments on commit 715e34f

Please sign in to comment.