mirror of
https://github.com/biersoeckli/QuickStack.git
synced 2026-01-01 17:20:14 -06:00
added hostname check component
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { AuthFormInputSchema, authFormInputSchemaZod, RegisterFormInputSchema, registgerFormInputSchemaZod } from "@/model/auth-form";
|
||||
import { SuccessActionResult } from "@/model/server-action-error-return.model";
|
||||
import { ServiceException } from "@/model/service.exception.model";
|
||||
import paramService, { ParamService } from "@/server/services/param.service";
|
||||
import quickStackService from "@/server/services/qs.service";
|
||||
import userService from "@/server/services/user.service";
|
||||
import { saveFormAction } from "@/server/utils/action-wrapper.utils";
|
||||
@@ -18,6 +19,10 @@ export const registerUser = async (prevState: any, inputData: RegisterFormInputS
|
||||
await quickStackService.createOrUpdateCertIssuer(validatedData.email);
|
||||
if (validatedData.qsHostname) {
|
||||
const url = new URL(validatedData.qsHostname.includes('://') ? validatedData.qsHostname : `https://${validatedData.qsHostname}`);
|
||||
await paramService.save({
|
||||
name: ParamService.QS_SERVER_HOSTNAME,
|
||||
value: url.hostname
|
||||
});
|
||||
await quickStackService.createOrUpdateIngress(url.hostname);
|
||||
return new SuccessActionResult(undefined, 'QuickStack is now available at: ' + url.href);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import ProjectPage from "./projects/project-page";
|
||||
import paramService, { ParamService } from "@/server/services/param.service";
|
||||
import HostnameCheck from "../components/custom/hostname-check";
|
||||
|
||||
export default function Home() {
|
||||
return <ProjectPage />;
|
||||
export default async function Home() {
|
||||
const configuredDomain = await paramService.getString(ParamService.QS_SERVER_HOSTNAME);
|
||||
return <>
|
||||
<ProjectPage />
|
||||
<HostnameCheck serverParamHostname={configuredDomain} />
|
||||
</>;
|
||||
}
|
||||
|
||||
28
src/components/custom/hostname-check.tsx
Normal file
28
src/components/custom/hostname-check.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
'use client'
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import ProjectPage from "../../app/projects/project-page";
|
||||
import paramService, { ParamService } from "@/server/services/param.service";
|
||||
import { cookies } from "next/headers";
|
||||
import { toast } from "sonner";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default function HostnameCheck({ serverParamHostname }: { serverParamHostname?: string }) {
|
||||
useEffect(() => {
|
||||
const hostname = window.location.hostname;
|
||||
if (serverParamHostname && serverParamHostname !== hostname) {
|
||||
toast.warning(`QuickStack is configured to run on a different domain. Please open the application on https://${serverParamHostname}`, {
|
||||
duration: 10000,
|
||||
action: {
|
||||
label: 'Open',
|
||||
onClick: () => {
|
||||
window.location.href = `https://${serverParamHostname}`;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [serverParamHostname]);
|
||||
return <></>;
|
||||
}
|
||||
@@ -7,7 +7,7 @@ export const authFormInputSchemaZod = z.object({
|
||||
export type AuthFormInputSchema = z.infer<typeof authFormInputSchemaZod>;
|
||||
|
||||
export const registgerFormInputSchemaZod = authFormInputSchemaZod.merge(z.object({
|
||||
qsHostname: z.string().url().optional(),
|
||||
qsHostname: z.string().trim().optional(),
|
||||
}));
|
||||
export type RegisterFormInputSchema = z.infer<typeof registgerFormInputSchemaZod>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user