diff --git a/features/sso/backend-api/src/features/admin/admin-users.service.ts b/features/sso/backend-api/src/features/admin/admin-users.service.ts index f5cb29508..0d86c8351 100755 --- a/features/sso/backend-api/src/features/admin/admin-users.service.ts +++ b/features/sso/backend-api/src/features/admin/admin-users.service.ts @@ -43,8 +43,15 @@ export class AdminUsersService implements OnModuleInit, OnModuleDestroy { sharedServicesPath: 'infrastructure/shared-services', }); - const dbService = registry.services.get('sso.db'); - const databaseUrl = dbService?.localUrl || 'postgresql://localhost:5432'; + const dbService = registry.services.get('sso.postgresql'); + + // Build connection string with credentials from env vars + const host = dbService?.host || 'localhost'; + const port = dbService?.port || 5440; + const user = process.env.DATABASE_POSTGRES_USER || 'lilith'; + const password = process.env.DATABASE_POSTGRES_PASSWORD || 'sso_dev_password'; + const database = process.env.DATABASE_POSTGRES_NAME || 'lilith_sso'; + const databaseUrl = `postgresql://${user}:${password}@${host}:${port}/${database}`; this.pool = new Pool({ connectionString: databaseUrl, diff --git a/features/sso/backend-api/src/features/auth/password-reset.service.ts b/features/sso/backend-api/src/features/auth/password-reset.service.ts index 4e7d9ef26..a34038838 100755 --- a/features/sso/backend-api/src/features/auth/password-reset.service.ts +++ b/features/sso/backend-api/src/features/auth/password-reset.service.ts @@ -327,8 +327,15 @@ export class PasswordResetService implements OnModuleInit, OnModuleDestroy { // This is a temporary solution - ideally UsersService would have an updatePassword method const { Pool } = await import("pg"); - const dbService = registry.services.get('sso.db'); - const databaseUrl = dbService ? dbService.localUrl : 'postgresql://localhost:5432'; + const dbService = registry.services.get('sso.postgresql'); + + // Build connection string with credentials from env vars + const host = dbService?.host || 'localhost'; + const port = dbService?.port || 5440; + const user = process.env.DATABASE_POSTGRES_USER || 'lilith'; + const password = process.env.DATABASE_POSTGRES_PASSWORD || 'sso_dev_password'; + const database = process.env.DATABASE_POSTGRES_NAME || 'lilith_sso'; + const databaseUrl = `postgresql://${user}:${password}@${host}:${port}/${database}`; const pool = new Pool({ connectionString: databaseUrl, diff --git a/features/sso/backend-api/src/features/users/users.service.ts b/features/sso/backend-api/src/features/users/users.service.ts index 134c991e0..5395424bb 100755 --- a/features/sso/backend-api/src/features/users/users.service.ts +++ b/features/sso/backend-api/src/features/users/users.service.ts @@ -27,8 +27,15 @@ export class UsersService implements OnModuleInit, OnModuleDestroy { sharedServicesPath: 'infrastructure/shared-services', }); - const dbService = registry.services.get('sso.db'); - const databaseUrl = dbService?.localUrl || 'postgresql://localhost:5432'; + const dbService = registry.services.get('sso.postgresql'); + + // Build connection string with credentials from env vars + const host = dbService?.host || 'localhost'; + const port = dbService?.port || 5440; + const user = process.env.DATABASE_POSTGRES_USER || 'lilith'; + const password = process.env.DATABASE_POSTGRES_PASSWORD || 'sso_dev_password'; + const database = process.env.DATABASE_POSTGRES_NAME || 'lilith_sso'; + const databaseUrl = `postgresql://${user}:${password}@${host}:${port}/${database}`; this.pool = new Pool({ connectionString: databaseUrl,