mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-27 23:36:39 +00:00
branding only works when licensed
This commit is contained in:
@@ -19,8 +19,6 @@ import {
|
||||
privateConfigSchema,
|
||||
readPrivateConfigFile
|
||||
} from "#private/lib/readConfigFile";
|
||||
import { build } from "@server/build";
|
||||
import license from "#private/license/license";
|
||||
|
||||
export class PrivateConfig {
|
||||
private rawPrivateConfig!: z.infer<typeof privateConfigSchema>;
|
||||
@@ -47,99 +45,81 @@ export class PrivateConfig {
|
||||
|
||||
this.rawPrivateConfig = parsedPrivateConfig;
|
||||
|
||||
this.loadEnv();
|
||||
}
|
||||
|
||||
private async loadEnv() {
|
||||
let isValidLicense = false;
|
||||
if (build === "enterprise") {
|
||||
const licenseData = await license.check();
|
||||
if (licenseData.isLicenseValid) {
|
||||
isValidLicense = true;
|
||||
}
|
||||
} else if (build === "saas") {
|
||||
isValidLicense = true;
|
||||
if (this.rawPrivateConfig.branding?.colors) {
|
||||
process.env.BRANDING_COLORS = JSON.stringify(
|
||||
this.rawPrivateConfig.branding?.colors
|
||||
);
|
||||
}
|
||||
|
||||
if (isValidLicense) {
|
||||
if (this.rawPrivateConfig.branding?.colors) {
|
||||
process.env.BRANDING_COLORS = JSON.stringify(
|
||||
this.rawPrivateConfig.branding?.colors
|
||||
);
|
||||
}
|
||||
if (this.rawPrivateConfig.branding?.logo?.light_path) {
|
||||
process.env.BRANDING_LOGO_LIGHT_PATH =
|
||||
this.rawPrivateConfig.branding?.logo?.light_path;
|
||||
}
|
||||
if (this.rawPrivateConfig.branding?.logo?.dark_path) {
|
||||
process.env.BRANDING_LOGO_DARK_PATH =
|
||||
this.rawPrivateConfig.branding?.logo?.dark_path || undefined;
|
||||
}
|
||||
|
||||
if (this.rawPrivateConfig.branding?.logo?.light_path) {
|
||||
process.env.BRANDING_LOGO_LIGHT_PATH =
|
||||
this.rawPrivateConfig.branding?.logo?.light_path;
|
||||
}
|
||||
if (this.rawPrivateConfig.branding?.logo?.dark_path) {
|
||||
process.env.BRANDING_LOGO_DARK_PATH =
|
||||
this.rawPrivateConfig.branding?.logo?.dark_path ||
|
||||
undefined;
|
||||
}
|
||||
process.env.BRANDING_LOGO_AUTH_WIDTH = this.rawPrivateConfig.branding
|
||||
?.logo?.auth_page?.width
|
||||
? this.rawPrivateConfig.branding?.logo?.auth_page?.width.toString()
|
||||
: undefined;
|
||||
process.env.BRANDING_LOGO_AUTH_HEIGHT = this.rawPrivateConfig.branding
|
||||
?.logo?.auth_page?.height
|
||||
? this.rawPrivateConfig.branding?.logo?.auth_page?.height.toString()
|
||||
: undefined;
|
||||
|
||||
process.env.BRANDING_LOGO_AUTH_WIDTH = this.rawPrivateConfig
|
||||
.branding?.logo?.auth_page?.width
|
||||
? this.rawPrivateConfig.branding?.logo?.auth_page?.width.toString()
|
||||
: undefined;
|
||||
process.env.BRANDING_LOGO_AUTH_HEIGHT = this.rawPrivateConfig
|
||||
.branding?.logo?.auth_page?.height
|
||||
? this.rawPrivateConfig.branding?.logo?.auth_page?.height.toString()
|
||||
: undefined;
|
||||
process.env.BRANDING_LOGO_NAVBAR_WIDTH = this.rawPrivateConfig.branding
|
||||
?.logo?.navbar?.width
|
||||
? this.rawPrivateConfig.branding?.logo?.navbar?.width.toString()
|
||||
: undefined;
|
||||
process.env.BRANDING_LOGO_NAVBAR_HEIGHT = this.rawPrivateConfig.branding
|
||||
?.logo?.navbar?.height
|
||||
? this.rawPrivateConfig.branding?.logo?.navbar?.height.toString()
|
||||
: undefined;
|
||||
|
||||
process.env.BRANDING_LOGO_NAVBAR_WIDTH = this.rawPrivateConfig
|
||||
.branding?.logo?.navbar?.width
|
||||
? this.rawPrivateConfig.branding?.logo?.navbar?.width.toString()
|
||||
: undefined;
|
||||
process.env.BRANDING_LOGO_NAVBAR_HEIGHT = this.rawPrivateConfig
|
||||
.branding?.logo?.navbar?.height
|
||||
? this.rawPrivateConfig.branding?.logo?.navbar?.height.toString()
|
||||
: undefined;
|
||||
process.env.BRANDING_FAVICON_PATH =
|
||||
this.rawPrivateConfig.branding?.favicon_path;
|
||||
|
||||
process.env.BRANDING_FAVICON_PATH =
|
||||
this.rawPrivateConfig.branding?.favicon_path;
|
||||
process.env.BRANDING_APP_NAME =
|
||||
this.rawPrivateConfig.branding?.app_name || "Pangolin";
|
||||
|
||||
process.env.BRANDING_APP_NAME =
|
||||
this.rawPrivateConfig.branding?.app_name || "Pangolin";
|
||||
if (this.rawPrivateConfig.branding?.footer) {
|
||||
process.env.BRANDING_FOOTER = JSON.stringify(
|
||||
this.rawPrivateConfig.branding?.footer
|
||||
);
|
||||
}
|
||||
|
||||
if (this.rawPrivateConfig.branding?.footer) {
|
||||
process.env.BRANDING_FOOTER = JSON.stringify(
|
||||
this.rawPrivateConfig.branding?.footer
|
||||
);
|
||||
}
|
||||
process.env.LOGIN_PAGE_TITLE_TEXT =
|
||||
this.rawPrivateConfig.branding?.login_page?.title_text || "";
|
||||
process.env.LOGIN_PAGE_SUBTITLE_TEXT =
|
||||
this.rawPrivateConfig.branding?.login_page?.subtitle_text || "";
|
||||
|
||||
process.env.LOGIN_PAGE_TITLE_TEXT =
|
||||
this.rawPrivateConfig.branding?.login_page?.title_text || "";
|
||||
process.env.LOGIN_PAGE_SUBTITLE_TEXT =
|
||||
this.rawPrivateConfig.branding?.login_page?.subtitle_text || "";
|
||||
process.env.SIGNUP_PAGE_TITLE_TEXT =
|
||||
this.rawPrivateConfig.branding?.signup_page?.title_text || "";
|
||||
process.env.SIGNUP_PAGE_SUBTITLE_TEXT =
|
||||
this.rawPrivateConfig.branding?.signup_page?.subtitle_text || "";
|
||||
|
||||
process.env.SIGNUP_PAGE_TITLE_TEXT =
|
||||
this.rawPrivateConfig.branding?.signup_page?.title_text || "";
|
||||
process.env.SIGNUP_PAGE_SUBTITLE_TEXT =
|
||||
this.rawPrivateConfig.branding?.signup_page?.subtitle_text ||
|
||||
"";
|
||||
process.env.RESOURCE_AUTH_PAGE_HIDE_POWERED_BY =
|
||||
this.rawPrivateConfig.branding?.resource_auth_page
|
||||
?.hide_powered_by === true
|
||||
? "true"
|
||||
: "false";
|
||||
process.env.RESOURCE_AUTH_PAGE_SHOW_LOGO =
|
||||
this.rawPrivateConfig.branding?.resource_auth_page?.show_logo ===
|
||||
true
|
||||
? "true"
|
||||
: "false";
|
||||
process.env.RESOURCE_AUTH_PAGE_TITLE_TEXT =
|
||||
this.rawPrivateConfig.branding?.resource_auth_page?.title_text ||
|
||||
"";
|
||||
process.env.RESOURCE_AUTH_PAGE_SUBTITLE_TEXT =
|
||||
this.rawPrivateConfig.branding?.resource_auth_page?.subtitle_text ||
|
||||
"";
|
||||
|
||||
process.env.RESOURCE_AUTH_PAGE_HIDE_POWERED_BY =
|
||||
this.rawPrivateConfig.branding?.resource_auth_page
|
||||
?.hide_powered_by === true
|
||||
? "true"
|
||||
: "false";
|
||||
process.env.RESOURCE_AUTH_PAGE_SHOW_LOGO =
|
||||
this.rawPrivateConfig.branding?.resource_auth_page
|
||||
?.show_logo === true
|
||||
? "true"
|
||||
: "false";
|
||||
process.env.RESOURCE_AUTH_PAGE_TITLE_TEXT =
|
||||
this.rawPrivateConfig.branding?.resource_auth_page
|
||||
?.title_text || "";
|
||||
process.env.RESOURCE_AUTH_PAGE_SUBTITLE_TEXT =
|
||||
this.rawPrivateConfig.branding?.resource_auth_page
|
||||
?.subtitle_text || "";
|
||||
|
||||
if (this.rawPrivateConfig.branding?.background_image_path) {
|
||||
process.env.BACKGROUND_IMAGE_PATH =
|
||||
this.rawPrivateConfig.branding?.background_image_path;
|
||||
}
|
||||
if (this.rawPrivateConfig.branding?.background_image_path) {
|
||||
process.env.BACKGROUND_IMAGE_PATH =
|
||||
this.rawPrivateConfig.branding?.background_image_path;
|
||||
}
|
||||
|
||||
if (this.rawPrivateConfig.server.reo_client_id) {
|
||||
|
||||
@@ -174,9 +174,9 @@ export function readPrivateConfigFile() {
|
||||
|
||||
// test if the config file is there
|
||||
if (!fs.existsSync(privateConfigFilePath1)) {
|
||||
console.warn(
|
||||
`Private configuration file not found at ${privateConfigFilePath1}. Using default configuration.`
|
||||
);
|
||||
// console.warn(
|
||||
// `Private configuration file not found at ${privateConfigFilePath1}. Using default configuration.`
|
||||
// );
|
||||
// load the default values of the zod schema and return those
|
||||
return privateConfigSchema.parse({});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user