mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-28 22:00:51 +00:00
♻️ make logo URL optional
This commit is contained in:
committed by
Owen Schwartz
parent
c92b5942fc
commit
b7df8b7319
@@ -11,6 +11,7 @@ import {
|
||||
GetLoginPageResponse
|
||||
} from "@server/routers/loginPage/types";
|
||||
import { AxiosResponse } from "axios";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export interface AuthPageProps {
|
||||
params: Promise<{ orgId: string }>;
|
||||
@@ -18,6 +19,12 @@ export interface AuthPageProps {
|
||||
|
||||
export default async function AuthPage(props: AuthPageProps) {
|
||||
const orgId = (await props.params).orgId;
|
||||
|
||||
// custom auth branding is only available in enterprise and saas
|
||||
if (build === "oss") {
|
||||
redirect(`/${orgId}/settings/general/`);
|
||||
}
|
||||
|
||||
let subscriptionStatus: GetOrgTierResponse | null = null;
|
||||
try {
|
||||
const subRes = await getCachedSubscription(orgId);
|
||||
|
||||
@@ -42,24 +42,27 @@ export type AuthPageCustomizationProps = {
|
||||
};
|
||||
|
||||
const AuthPageFormSchema = z.object({
|
||||
logoUrl: z.url().refine(
|
||||
async (url) => {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
return (
|
||||
response.status === 200 &&
|
||||
(response.headers.get("content-type") ?? "").startsWith(
|
||||
"image/"
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
return false;
|
||||
logoUrl: z.union([
|
||||
z.string().length(0),
|
||||
z.url().refine(
|
||||
async (url) => {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
return (
|
||||
response.status === 200 &&
|
||||
(response.headers.get("content-type") ?? "").startsWith(
|
||||
"image/"
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
{
|
||||
error: "Invalid logo URL, must be a valid image URL"
|
||||
}
|
||||
},
|
||||
{
|
||||
error: "Invalid logo URL, must be a valid image URL"
|
||||
}
|
||||
),
|
||||
)
|
||||
]),
|
||||
logoWidth: z.coerce.number<number>().min(1),
|
||||
logoHeight: z.coerce.number<number>().min(1),
|
||||
orgTitle: z.string().optional(),
|
||||
@@ -90,7 +93,6 @@ export default function AuthPageBrandingForm({
|
||||
deleteBranding,
|
||||
null
|
||||
);
|
||||
const [setIsDeleteModalOpen] = useState(false);
|
||||
|
||||
const t = useTranslations();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import Image from "next/image";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
type BrandingLogoProps = {
|
||||
logoPath?: string;
|
||||
logoPath?: string | null;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
|
||||
@@ -88,7 +88,7 @@ type ResourceAuthPortalProps = {
|
||||
idps?: LoginFormIDP[];
|
||||
orgId?: string;
|
||||
branding?: {
|
||||
logoUrl: string;
|
||||
logoUrl?: string | null;
|
||||
logoWidth: number;
|
||||
logoHeight: number;
|
||||
primaryColor: string | null;
|
||||
|
||||
Reference in New Issue
Block a user