Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-mixed-operators */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types, camelcase */
import {
Expand Down
29 changes: 19 additions & 10 deletions libs/prisma-service/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,17 +680,26 @@ export async function createKeycloakUser(): Promise<void> {
CRYPTO_PRIVATE_KEY
} = process.env;

if (
!KEYCLOAK_DOMAIN ||
!KEYCLOAK_REALM ||
!PLATFORM_ADMIN_KEYCLOAK_ID ||
!PLATFORM_ADMIN_KEYCLOAK_SECRET ||
!CRYPTO_PRIVATE_KEY
) {
throw new Error(
'Missing required environment variables for either PLATFORM_ADMIN_USER_PASSWORD or KEYCLOAK_DOMAIN or KEYCLOAK_REALM or PLATFORM_ADMIN_KEYCLOAK_ID or PLATFORM_ADMIN_KEYCLOAK_SECRET or CRYPTO_PRIVATE_KEY'
);
if (!KEYCLOAK_DOMAIN) {
throw new Error('Missing environment variable: KEYCLOAK_DOMAIN');
}

if (!KEYCLOAK_REALM) {
throw new Error('Missing environment variable: KEYCLOAK_REALM');
}

if (!PLATFORM_ADMIN_KEYCLOAK_ID) {
throw new Error('Missing environment variable: PLATFORM_ADMIN_KEYCLOAK_ID');
}

if (!PLATFORM_ADMIN_KEYCLOAK_SECRET) {
throw new Error('Missing environment variable: PLATFORM_ADMIN_KEYCLOAK_SECRET');
}

if (!CRYPTO_PRIVATE_KEY) {
throw new Error('Missing environment variable: CRYPTO_PRIVATE_KEY');
}

const decryptedPassword = CryptoJS.AES.decrypt(platformAdminData.password, CRYPTO_PRIVATE_KEY);
const token = await getKeycloakToken();
const user = {
Expand Down
Loading