feat: isServiceConfigured modified

This commit is contained in:
mirarifhasan 2024-04-17 18:03:04 +06:00
parent 6517c444e8
commit eaa6f105bb
2 changed files with 5 additions and 21 deletions

View File

@ -13,7 +13,7 @@ export enum ServiceStatus {
DISABLE = 'DISABLE',
}
const AuthProviderConfigurations = {
export const AuthProviderConfigurations = {
[AuthProvider.GOOGLE]: [
InfraConfigEnum.GOOGLE_CLIENT_ID,
InfraConfigEnum.GOOGLE_CLIENT_SECRET,

View File

@ -22,6 +22,7 @@ import {
} from 'src/utils';
import { ConfigService } from '@nestjs/config';
import {
AuthProviderConfigurations,
ServiceStatus,
getDefaultInfraConfigs,
getMissingInfraConfigEntries,
@ -174,29 +175,12 @@ export class InfraConfigService implements OnModuleInit {
) {
switch (service) {
case AuthProvider.GOOGLE:
return (
configMap.GOOGLE_CLIENT_ID &&
configMap.GOOGLE_CLIENT_SECRET &&
configMap.GOOGLE_CALLBACK_URL &&
configMap.GOOGLE_SCOPE
);
case AuthProvider.GITHUB:
return (
configMap.GITHUB_CLIENT_ID &&
configMap.GITHUB_CLIENT_SECRET &&
configMap.GITHUB_CALLBACK_URL &&
configMap.GITHUB_SCOPE
);
case AuthProvider.MICROSOFT:
return (
configMap.MICROSOFT_CLIENT_ID &&
configMap.MICROSOFT_CLIENT_SECRET &&
configMap.MICROSOFT_CALLBACK_URL &&
configMap.MICROSOFT_SCOPE &&
configMap.MICROSOFT_TENANT
);
case AuthProvider.EMAIL:
return configMap.MAILER_SMTP_URL && configMap.MAILER_ADDRESS_FROM;
const requiredConfigs = AuthProviderConfigurations[service];
if (!requiredConfigs) return false;
return requiredConfigs.every((config) => configMap[config]);
default:
return false;
}