mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-07 03:06:40 +00:00
branding only works when licensed
This commit is contained in:
@@ -19,11 +19,16 @@ import { setHostMeta } from "@server/lib/hostMeta";
|
|||||||
import { initTelemetryClient } from "./lib/telemetry.js";
|
import { initTelemetryClient } from "./lib/telemetry.js";
|
||||||
import { TraefikConfigManager } from "./lib/traefik/TraefikConfigManager.js";
|
import { TraefikConfigManager } from "./lib/traefik/TraefikConfigManager.js";
|
||||||
import { initCleanup } from "#dynamic/cleanup";
|
import { initCleanup } from "#dynamic/cleanup";
|
||||||
|
import license from "#dynamic/license/license";
|
||||||
|
|
||||||
async function startServers() {
|
async function startServers() {
|
||||||
await setHostMeta();
|
await setHostMeta();
|
||||||
|
|
||||||
await config.initServer();
|
await config.initServer();
|
||||||
|
|
||||||
|
license.setServerSecret(config.getRawConfig().server.secret!);
|
||||||
|
await license.check();
|
||||||
|
|
||||||
await runSetupFunctions();
|
await runSetupFunctions();
|
||||||
|
|
||||||
initTelemetryClient();
|
initTelemetryClient();
|
||||||
|
|||||||
@@ -3,11 +3,9 @@ import { __DIRNAME, APP_VERSION } from "@server/lib/consts";
|
|||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { SupporterKey, supporterKey } from "@server/db";
|
import { SupporterKey, supporterKey } from "@server/db";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { license } from "#dynamic/license/license";
|
|
||||||
import { configSchema, readConfigFile } from "./readConfigFile";
|
import { configSchema, readConfigFile } from "./readConfigFile";
|
||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
import logger from "@server/logger";
|
|
||||||
|
|
||||||
export class Config {
|
export class Config {
|
||||||
private rawConfig!: z.infer<typeof configSchema>;
|
private rawConfig!: z.infer<typeof configSchema>;
|
||||||
@@ -103,16 +101,10 @@ export class Config {
|
|||||||
throw new Error("Config not loaded. Call load() first.");
|
throw new Error("Config not loaded. Call load() first.");
|
||||||
}
|
}
|
||||||
|
|
||||||
license.setServerSecret(this.rawConfig.server.secret!);
|
|
||||||
|
|
||||||
await this.checkKeyStatus();
|
await this.checkKeyStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async checkKeyStatus() {
|
private async checkKeyStatus() {
|
||||||
if (build === "enterprise") {
|
|
||||||
await license.check();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (build == "oss") {
|
if (build == "oss") {
|
||||||
this.checkSupporterKey();
|
this.checkSupporterKey();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import {
|
|||||||
privateConfigSchema,
|
privateConfigSchema,
|
||||||
readPrivateConfigFile
|
readPrivateConfigFile
|
||||||
} from "#private/lib/readConfigFile";
|
} from "#private/lib/readConfigFile";
|
||||||
import { build } from "@server/build";
|
|
||||||
import license from "#private/license/license";
|
|
||||||
|
|
||||||
export class PrivateConfig {
|
export class PrivateConfig {
|
||||||
private rawPrivateConfig!: z.infer<typeof privateConfigSchema>;
|
private rawPrivateConfig!: z.infer<typeof privateConfigSchema>;
|
||||||
@@ -47,99 +45,81 @@ export class PrivateConfig {
|
|||||||
|
|
||||||
this.rawPrivateConfig = parsedPrivateConfig;
|
this.rawPrivateConfig = parsedPrivateConfig;
|
||||||
|
|
||||||
this.loadEnv();
|
if (this.rawPrivateConfig.branding?.colors) {
|
||||||
}
|
process.env.BRANDING_COLORS = JSON.stringify(
|
||||||
|
this.rawPrivateConfig.branding?.colors
|
||||||
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 (isValidLicense) {
|
if (this.rawPrivateConfig.branding?.logo?.light_path) {
|
||||||
if (this.rawPrivateConfig.branding?.colors) {
|
process.env.BRANDING_LOGO_LIGHT_PATH =
|
||||||
process.env.BRANDING_COLORS = JSON.stringify(
|
this.rawPrivateConfig.branding?.logo?.light_path;
|
||||||
this.rawPrivateConfig.branding?.colors
|
}
|
||||||
);
|
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_AUTH_WIDTH = this.rawPrivateConfig.branding
|
||||||
process.env.BRANDING_LOGO_LIGHT_PATH =
|
?.logo?.auth_page?.width
|
||||||
this.rawPrivateConfig.branding?.logo?.light_path;
|
? this.rawPrivateConfig.branding?.logo?.auth_page?.width.toString()
|
||||||
}
|
: undefined;
|
||||||
if (this.rawPrivateConfig.branding?.logo?.dark_path) {
|
process.env.BRANDING_LOGO_AUTH_HEIGHT = this.rawPrivateConfig.branding
|
||||||
process.env.BRANDING_LOGO_DARK_PATH =
|
?.logo?.auth_page?.height
|
||||||
this.rawPrivateConfig.branding?.logo?.dark_path ||
|
? this.rawPrivateConfig.branding?.logo?.auth_page?.height.toString()
|
||||||
undefined;
|
: undefined;
|
||||||
}
|
|
||||||
|
|
||||||
process.env.BRANDING_LOGO_AUTH_WIDTH = this.rawPrivateConfig
|
process.env.BRANDING_LOGO_NAVBAR_WIDTH = this.rawPrivateConfig.branding
|
||||||
.branding?.logo?.auth_page?.width
|
?.logo?.navbar?.width
|
||||||
? this.rawPrivateConfig.branding?.logo?.auth_page?.width.toString()
|
? this.rawPrivateConfig.branding?.logo?.navbar?.width.toString()
|
||||||
: undefined;
|
: undefined;
|
||||||
process.env.BRANDING_LOGO_AUTH_HEIGHT = this.rawPrivateConfig
|
process.env.BRANDING_LOGO_NAVBAR_HEIGHT = this.rawPrivateConfig.branding
|
||||||
.branding?.logo?.auth_page?.height
|
?.logo?.navbar?.height
|
||||||
? this.rawPrivateConfig.branding?.logo?.auth_page?.height.toString()
|
? this.rawPrivateConfig.branding?.logo?.navbar?.height.toString()
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
process.env.BRANDING_LOGO_NAVBAR_WIDTH = this.rawPrivateConfig
|
process.env.BRANDING_FAVICON_PATH =
|
||||||
.branding?.logo?.navbar?.width
|
this.rawPrivateConfig.branding?.favicon_path;
|
||||||
? 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 =
|
process.env.BRANDING_APP_NAME =
|
||||||
this.rawPrivateConfig.branding?.favicon_path;
|
this.rawPrivateConfig.branding?.app_name || "Pangolin";
|
||||||
|
|
||||||
process.env.BRANDING_APP_NAME =
|
if (this.rawPrivateConfig.branding?.footer) {
|
||||||
this.rawPrivateConfig.branding?.app_name || "Pangolin";
|
process.env.BRANDING_FOOTER = JSON.stringify(
|
||||||
|
this.rawPrivateConfig.branding?.footer
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.rawPrivateConfig.branding?.footer) {
|
process.env.LOGIN_PAGE_TITLE_TEXT =
|
||||||
process.env.BRANDING_FOOTER = JSON.stringify(
|
this.rawPrivateConfig.branding?.login_page?.title_text || "";
|
||||||
this.rawPrivateConfig.branding?.footer
|
process.env.LOGIN_PAGE_SUBTITLE_TEXT =
|
||||||
);
|
this.rawPrivateConfig.branding?.login_page?.subtitle_text || "";
|
||||||
}
|
|
||||||
|
|
||||||
process.env.LOGIN_PAGE_TITLE_TEXT =
|
process.env.SIGNUP_PAGE_TITLE_TEXT =
|
||||||
this.rawPrivateConfig.branding?.login_page?.title_text || "";
|
this.rawPrivateConfig.branding?.signup_page?.title_text || "";
|
||||||
process.env.LOGIN_PAGE_SUBTITLE_TEXT =
|
process.env.SIGNUP_PAGE_SUBTITLE_TEXT =
|
||||||
this.rawPrivateConfig.branding?.login_page?.subtitle_text || "";
|
this.rawPrivateConfig.branding?.signup_page?.subtitle_text || "";
|
||||||
|
|
||||||
process.env.SIGNUP_PAGE_TITLE_TEXT =
|
process.env.RESOURCE_AUTH_PAGE_HIDE_POWERED_BY =
|
||||||
this.rawPrivateConfig.branding?.signup_page?.title_text || "";
|
this.rawPrivateConfig.branding?.resource_auth_page
|
||||||
process.env.SIGNUP_PAGE_SUBTITLE_TEXT =
|
?.hide_powered_by === true
|
||||||
this.rawPrivateConfig.branding?.signup_page?.subtitle_text ||
|
? "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 =
|
if (this.rawPrivateConfig.branding?.background_image_path) {
|
||||||
this.rawPrivateConfig.branding?.resource_auth_page
|
process.env.BACKGROUND_IMAGE_PATH =
|
||||||
?.hide_powered_by === true
|
this.rawPrivateConfig.branding?.background_image_path;
|
||||||
? "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.server.reo_client_id) {
|
if (this.rawPrivateConfig.server.reo_client_id) {
|
||||||
|
|||||||
@@ -174,9 +174,9 @@ export function readPrivateConfigFile() {
|
|||||||
|
|
||||||
// test if the config file is there
|
// test if the config file is there
|
||||||
if (!fs.existsSync(privateConfigFilePath1)) {
|
if (!fs.existsSync(privateConfigFilePath1)) {
|
||||||
console.warn(
|
// console.warn(
|
||||||
`Private configuration file not found at ${privateConfigFilePath1}. Using default configuration.`
|
// `Private configuration file not found at ${privateConfigFilePath1}. Using default configuration.`
|
||||||
);
|
// );
|
||||||
// load the default values of the zod schema and return those
|
// load the default values of the zod schema and return those
|
||||||
return privateConfigSchema.parse({});
|
return privateConfigSchema.parse({});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,12 @@ export default async function RootLayout({
|
|||||||
)
|
)
|
||||||
)();
|
)();
|
||||||
licenseStatus = licenseStatusRes.data.data;
|
licenseStatus = licenseStatusRes.data.data;
|
||||||
|
} else if (build === "saas") {
|
||||||
|
licenseStatus = {
|
||||||
|
isHostLicensed: true,
|
||||||
|
isLicenseValid: true,
|
||||||
|
hostId: "saas"
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
licenseStatus = {
|
licenseStatus = {
|
||||||
isHostLicensed: false,
|
isHostLicensed: false,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
|
import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext";
|
||||||
import { useTheme } from "next-themes";
|
import { useTheme } from "next-themes";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
@@ -13,6 +14,7 @@ type BrandingLogoProps = {
|
|||||||
export default function BrandingLogo(props: BrandingLogoProps) {
|
export default function BrandingLogo(props: BrandingLogoProps) {
|
||||||
const { env } = useEnvContext();
|
const { env } = useEnvContext();
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
|
const { isUnlocked } = useLicenseStatusContext();
|
||||||
const [path, setPath] = useState<string>(""); // Default logo path
|
const [path, setPath] = useState<string>(""); // Default logo path
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -27,12 +29,16 @@ export default function BrandingLogo(props: BrandingLogoProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lightOrDark === "light") {
|
if (lightOrDark === "light") {
|
||||||
return (
|
if (isUnlocked() && env.branding.logo?.lightPath) {
|
||||||
env.branding.logo?.lightPath || "/logo/word_mark_black.png"
|
return env.branding.logo.lightPath;
|
||||||
);
|
}
|
||||||
|
return "/logo/word_mark_black.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
return env.branding.logo?.darkPath || "/logo/word_mark_white.png";
|
if (isUnlocked() && env.branding.logo?.darkPath) {
|
||||||
|
return env.branding.logo.darkPath;
|
||||||
|
}
|
||||||
|
return "/logo/word_mark_white.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
const path = getPath();
|
const path = getPath();
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import Image from "next/image";
|
|||||||
import { cleanRedirect } from "@app/lib/cleanRedirect";
|
import { cleanRedirect } from "@app/lib/cleanRedirect";
|
||||||
import BrandingLogo from "@app/components/BrandingLogo";
|
import BrandingLogo from "@app/components/BrandingLogo";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext";
|
||||||
|
|
||||||
type DashboardLoginFormProps = {
|
type DashboardLoginFormProps = {
|
||||||
redirect?: string;
|
redirect?: string;
|
||||||
@@ -29,18 +30,22 @@ export default function DashboardLoginForm({
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { env } = useEnvContext();
|
const { env } = useEnvContext();
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
const { isUnlocked } = useLicenseStatusContext();
|
||||||
|
|
||||||
function getSubtitle() {
|
function getSubtitle() {
|
||||||
return t("loginStart");
|
return t("loginStart");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const logoWidth = isUnlocked() ? env.branding.logo?.authPage?.width || 175 : 175;
|
||||||
|
const logoHeight = isUnlocked() ? env.branding.logo?.authPage?.height || 58 : 58;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="shadow-md w-full max-w-md">
|
<Card className="shadow-md w-full max-w-md">
|
||||||
<CardHeader className="border-b">
|
<CardHeader className="border-b">
|
||||||
<div className="flex flex-row items-center justify-center">
|
<div className="flex flex-row items-center justify-center">
|
||||||
<BrandingLogo
|
<BrandingLogo
|
||||||
height={env.branding.logo?.authPage?.height || 58}
|
height={logoHeight}
|
||||||
width={env.branding.logo?.authPage?.width || 175}
|
width={logoWidth}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-center space-y-1 pt-3">
|
<div className="text-center space-y-1 pt-3">
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import Image from "next/image";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import ProfileIcon from "@app/components/ProfileIcon";
|
import ProfileIcon from "@app/components/ProfileIcon";
|
||||||
import ThemeSwitcher from "@app/components/ThemeSwitcher";
|
import ThemeSwitcher from "@app/components/ThemeSwitcher";
|
||||||
import { useTheme } from "next-themes";
|
import { useTheme } from "next-themes";
|
||||||
import BrandingLogo from "./BrandingLogo";
|
import BrandingLogo from "./BrandingLogo";
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
import { Badge } from "./ui/badge";
|
import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext";
|
||||||
import { build } from "@server/build";
|
|
||||||
|
|
||||||
interface LayoutHeaderProps {
|
interface LayoutHeaderProps {
|
||||||
showTopBar: boolean;
|
showTopBar: boolean;
|
||||||
@@ -19,6 +17,14 @@ export function LayoutHeader({ showTopBar }: LayoutHeaderProps) {
|
|||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
const [path, setPath] = useState<string>("");
|
const [path, setPath] = useState<string>("");
|
||||||
const { env } = useEnvContext();
|
const { env } = useEnvContext();
|
||||||
|
const { isUnlocked } = useLicenseStatusContext();
|
||||||
|
|
||||||
|
const logoWidth = isUnlocked()
|
||||||
|
? env.branding.logo?.navbar?.width || 98
|
||||||
|
: 98;
|
||||||
|
const logoHeight = isUnlocked()
|
||||||
|
? env.branding.logo?.navbar?.height || 32
|
||||||
|
: 32;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function getPath() {
|
function getPath() {
|
||||||
@@ -50,12 +56,8 @@ export function LayoutHeader({ showTopBar }: LayoutHeaderProps) {
|
|||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Link href="/" className="flex items-center">
|
<Link href="/" className="flex items-center">
|
||||||
<BrandingLogo
|
<BrandingLogo
|
||||||
width={
|
width={logoWidth}
|
||||||
env.branding.logo?.navbar?.width || 98
|
height={logoHeight}
|
||||||
}
|
|
||||||
height={
|
|
||||||
env.branding.logo?.navbar?.height || 32
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</Link>
|
</Link>
|
||||||
{/* {build === "saas" && (
|
{/* {build === "saas" && (
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ export function LayoutSidebar({
|
|||||||
}, [isSidebarCollapsed]);
|
}, [isSidebarCollapsed]);
|
||||||
|
|
||||||
function loadFooterLinks(): { text: string; href?: string }[] | undefined {
|
function loadFooterLinks(): { text: string; href?: string }[] | undefined {
|
||||||
|
if (!isUnlocked()) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
if (env.branding.footer) {
|
if (env.branding.footer) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(env.branding.footer);
|
return JSON.parse(env.branding.footer);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import BrandingLogo from "@app/components/BrandingLogo";
|
|||||||
import { useSupporterStatusContext } from "@app/hooks/useSupporterStatusContext";
|
import { useSupporterStatusContext } from "@app/hooks/useSupporterStatusContext";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
|
import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext";
|
||||||
|
|
||||||
const pinSchema = z.object({
|
const pinSchema = z.object({
|
||||||
pin: z
|
pin: z
|
||||||
@@ -92,6 +93,7 @@ type ResourceAuthPortalProps = {
|
|||||||
export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
|
export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
const { isUnlocked } = useLicenseStatusContext();
|
||||||
|
|
||||||
const getNumMethods = () => {
|
const getNumMethods = () => {
|
||||||
let colLength = 0;
|
let colLength = 0;
|
||||||
@@ -308,14 +310,22 @@ export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getTitle() {
|
function getTitle() {
|
||||||
if (build !== "oss" && env.branding.resourceAuthPage?.titleText) {
|
if (
|
||||||
|
isUnlocked() &&
|
||||||
|
build !== "oss" &&
|
||||||
|
env.branding.resourceAuthPage?.titleText
|
||||||
|
) {
|
||||||
return env.branding.resourceAuthPage.titleText;
|
return env.branding.resourceAuthPage.titleText;
|
||||||
}
|
}
|
||||||
return t("authenticationRequired");
|
return t("authenticationRequired");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSubtitle(resourceName: string) {
|
function getSubtitle(resourceName: string) {
|
||||||
if (build !== "oss" && env.branding.resourceAuthPage?.subtitleText) {
|
if (
|
||||||
|
isUnlocked() &&
|
||||||
|
build !== "oss" &&
|
||||||
|
env.branding.resourceAuthPage?.subtitleText
|
||||||
|
) {
|
||||||
return env.branding.resourceAuthPage.subtitleText
|
return env.branding.resourceAuthPage.subtitleText
|
||||||
.split("{{resourceName}}")
|
.split("{{resourceName}}")
|
||||||
.join(resourceName);
|
.join(resourceName);
|
||||||
@@ -325,11 +335,14 @@ export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
|
|||||||
: t("authenticationRequest", { name: resourceName });
|
: t("authenticationRequest", { name: resourceName });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const logoWidth = isUnlocked() ? env.branding.logo?.authPage?.width || 100 : 100;
|
||||||
|
const logoHeight = isUnlocked() ? env.branding.logo?.authPage?.height || 100 : 100;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{!accessDenied ? (
|
{!accessDenied ? (
|
||||||
<div>
|
<div>
|
||||||
{build === "enterprise" ? (
|
{isUnlocked() && build === "enterprise" ? (
|
||||||
!env.branding.resourceAuthPage?.hidePoweredBy && (
|
!env.branding.resourceAuthPage?.hidePoweredBy && (
|
||||||
<div className="text-center mb-2">
|
<div className="text-center mb-2">
|
||||||
<span className="text-sm text-muted-foreground">
|
<span className="text-sm text-muted-foreground">
|
||||||
@@ -362,18 +375,13 @@ export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
|
|||||||
)}
|
)}
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
{build !== "oss" &&
|
{isUnlocked() &&
|
||||||
|
build !== "oss" &&
|
||||||
env.branding?.resourceAuthPage?.showLogo && (
|
env.branding?.resourceAuthPage?.showLogo && (
|
||||||
<div className="flex flex-row items-center justify-center mb-3">
|
<div className="flex flex-row items-center justify-center mb-3">
|
||||||
<BrandingLogo
|
<BrandingLogo
|
||||||
height={
|
height={logoHeight}
|
||||||
env.branding.logo?.authPage
|
width={logoWidth}
|
||||||
?.height || 100
|
|
||||||
}
|
|
||||||
width={
|
|
||||||
env.branding.logo?.authPage
|
|
||||||
?.width || 100
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
CardDescription,
|
|
||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle
|
|
||||||
} from "@/components/ui/card";
|
} from "@/components/ui/card";
|
||||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
import { Progress } from "@/components/ui/progress";
|
import { Progress } from "@/components/ui/progress";
|
||||||
@@ -31,13 +29,13 @@ import { AxiosResponse } from "axios";
|
|||||||
import { formatAxiosError } from "@app/lib/api";
|
import { formatAxiosError } from "@app/lib/api";
|
||||||
import { createApiClient } from "@app/lib/api";
|
import { createApiClient } from "@app/lib/api";
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
import Image from "next/image";
|
|
||||||
import { cleanRedirect } from "@app/lib/cleanRedirect";
|
import { cleanRedirect } from "@app/lib/cleanRedirect";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import BrandingLogo from "@app/components/BrandingLogo";
|
import BrandingLogo from "@app/components/BrandingLogo";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
import { Check, X } from "lucide-react";
|
import { Check, X } from "lucide-react";
|
||||||
import { cn } from "@app/lib/cn";
|
import { cn } from "@app/lib/cn";
|
||||||
|
import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext";
|
||||||
|
|
||||||
// Password strength calculation
|
// Password strength calculation
|
||||||
const calculatePasswordStrength = (password: string) => {
|
const calculatePasswordStrength = (password: string) => {
|
||||||
@@ -111,6 +109,7 @@ export default function SignupForm({
|
|||||||
const { env } = useEnvContext();
|
const { env } = useEnvContext();
|
||||||
const api = createApiClient({ env });
|
const api = createApiClient({ env });
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
const { isUnlocked } = useLicenseStatusContext();
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
@@ -192,14 +191,18 @@ export default function SignupForm({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const logoWidth = isUnlocked()
|
||||||
|
? env.branding.logo?.authPage?.width || 175
|
||||||
|
: 175;
|
||||||
|
const logoHeight = isUnlocked()
|
||||||
|
? env.branding.logo?.authPage?.height || 58
|
||||||
|
: 58;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="w-full max-w-md shadow-md">
|
<Card className="w-full max-w-md shadow-md">
|
||||||
<CardHeader className="border-b">
|
<CardHeader className="border-b">
|
||||||
<div className="flex flex-row items-center justify-center">
|
<div className="flex flex-row items-center justify-center">
|
||||||
<BrandingLogo
|
<BrandingLogo height={logoHeight} width={logoWidth} />
|
||||||
height={env.branding.logo?.authPage?.height || 58}
|
|
||||||
width={env.branding.logo?.authPage?.width || 175}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="text-center space-y-1 pt-3">
|
<div className="text-center space-y-1 pt-3">
|
||||||
<p className="text-muted-foreground">{getSubtitle()}</p>
|
<p className="text-muted-foreground">{getSubtitle()}</p>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext";
|
||||||
|
|
||||||
type SplashImageProps = {
|
type SplashImageProps = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
@@ -11,8 +12,12 @@ type SplashImageProps = {
|
|||||||
export default function SplashImage({ children }: SplashImageProps) {
|
export default function SplashImage({ children }: SplashImageProps) {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const { env } = useEnvContext();
|
const { env } = useEnvContext();
|
||||||
|
const { isUnlocked } = useLicenseStatusContext();
|
||||||
|
|
||||||
function showBackgroundImage() {
|
function showBackgroundImage() {
|
||||||
|
if (!isUnlocked()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!env.branding.background_image_path) {
|
if (!env.branding.background_image_path) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import LicenseStatusContext from "@app/contexts/licenseStatusContext";
|
import LicenseStatusContext from "@app/contexts/licenseStatusContext";
|
||||||
|
import { build } from "@server/build";
|
||||||
import { LicenseStatus } from "@server/license/license";
|
import { LicenseStatus } from "@server/license/license";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user