add NEXT_PUBLIC_ENABLE_SUBDOMAIN_APPLY env
This commit is contained in:
+5
-1
@@ -30,6 +30,9 @@ RESEND_FROM_EMAIL="wrdo <support@wr.do>"
|
||||
# Open Signup
|
||||
NEXT_PUBLIC_OPEN_SIGNUP=1
|
||||
|
||||
# Enable subdomain apply, default is false(0). If set to 1, will enable subdomain apply
|
||||
NEXT_PUBLIC_ENABLE_SUBDOMAIN_APPLY=1
|
||||
|
||||
# Google Analytics
|
||||
NEXT_PUBLIC_GOOGLE_ID=
|
||||
|
||||
@@ -41,4 +44,5 @@ GITHUB_TOKEN=
|
||||
|
||||
# Skip DB check and migration (only for docker), default is true. if false, will check and migrate database each time start docker compose.
|
||||
SKIP_DB_CHECK=true
|
||||
SKIP_DB_MIGRATION=true
|
||||
SKIP_DB_MIGRATION=true
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@ export default function UserRecordsList({ user, action }: RecordListProps) {
|
||||
useState<UserRecordFormData | null>(null);
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(10);
|
||||
const [tab, setTab] = useState("app");
|
||||
const isAdmin = action.includes("/admin");
|
||||
|
||||
const { mutate } = useSWRConfig();
|
||||
|
||||
@@ -136,11 +138,13 @@ export default function UserRecordsList({ user, action }: RecordListProps) {
|
||||
}
|
||||
};
|
||||
|
||||
const rendeApplyList = () => {};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Card className="xl:col-span-2">
|
||||
<CardHeader className="flex flex-row items-center">
|
||||
{action.includes("/admin") ? (
|
||||
{isAdmin ? (
|
||||
<CardDescription className="text-balance text-lg font-bold">
|
||||
<span>Total Subdomains:</span>{" "}
|
||||
<span className="font-bold">{data && data.total}</span>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { siteConfig } from "@/config/site";
|
||||
import { TeamPlanQuota } from "@/config/team";
|
||||
import { createDNSRecord } from "@/lib/cloudflare";
|
||||
import {
|
||||
@@ -75,10 +76,38 @@ export async function POST(req: Request) {
|
||||
);
|
||||
if (user_record && user_record.length > 0) {
|
||||
return Response.json("Record already exists", {
|
||||
status: 403,
|
||||
status: 400,
|
||||
});
|
||||
}
|
||||
|
||||
// apply subdomain
|
||||
if (siteConfig.enableSubdomainApply) {
|
||||
const res = await createUserRecord(user.id, {
|
||||
record_id: generateSecret(16),
|
||||
zone_id: matchedZone.cf_zone_id,
|
||||
zone_name: matchedZone.domain_name,
|
||||
name: record.name,
|
||||
type: record.type,
|
||||
content: record.content,
|
||||
proxied: record.proxied,
|
||||
proxiable: false,
|
||||
ttl: record.ttl,
|
||||
comment: record.comment,
|
||||
tags: "",
|
||||
created_on: new Date().toISOString(),
|
||||
modified_on: new Date().toISOString(),
|
||||
active: 2, // pending
|
||||
});
|
||||
|
||||
if (res.status !== "success") {
|
||||
return Response.json(res.status, {
|
||||
status: 502,
|
||||
});
|
||||
}
|
||||
// send email to admin
|
||||
return Response.json(res.data?.id);
|
||||
}
|
||||
|
||||
const data = await createDNSRecord(
|
||||
matchedZone.cf_zone_id,
|
||||
matchedZone.cf_api_key,
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export async function POST(req: Request) {}
|
||||
@@ -4,6 +4,7 @@ import { env } from "@/env.mjs";
|
||||
const site_url = env.NEXT_PUBLIC_APP_URL || "http://localhost:3030";
|
||||
const open_signup = env.NEXT_PUBLIC_OPEN_SIGNUP;
|
||||
const email_r2_domain = env.NEXT_PUBLIC_EMAIL_R2_DOMAIN || "";
|
||||
const enable_subdomain_apply = env.NEXT_PUBLIC_ENABLE_SUBDOMAIN_APPLY || "0";
|
||||
|
||||
export const siteConfig: SiteConfig = {
|
||||
name: "WR.DO",
|
||||
@@ -21,6 +22,7 @@ export const siteConfig: SiteConfig = {
|
||||
mailSupport: "support@wr.do",
|
||||
openSignup: open_signup === "1" ? true : false,
|
||||
emailR2Domain: email_r2_domain,
|
||||
enableSubdomainApply: enable_subdomain_apply === "1" ? true : false,
|
||||
};
|
||||
|
||||
export const footerLinks: SidebarNavItem[] = [
|
||||
|
||||
@@ -3,8 +3,6 @@ import { z } from "zod";
|
||||
|
||||
export const env = createEnv({
|
||||
server: {
|
||||
// This is optional because it's only used in development.
|
||||
// See https://next-auth.js.org/deployment.
|
||||
NEXTAUTH_URL: z.string().url().optional(),
|
||||
AUTH_SECRET: z.string().optional(),
|
||||
GOOGLE_CLIENT_ID: z.string().optional(),
|
||||
@@ -23,6 +21,7 @@ export const env = createEnv({
|
||||
NEXT_PUBLIC_APP_URL: z.string().optional(),
|
||||
NEXT_PUBLIC_OPEN_SIGNUP: z.string().min(1).default("1"),
|
||||
NEXT_PUBLIC_EMAIL_R2_DOMAIN: z.string().optional(),
|
||||
NEXT_PUBLIC_ENABLE_SUBDOMAIN_APPLY: z.string().min(1).default("0"),
|
||||
},
|
||||
runtimeEnv: {
|
||||
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
|
||||
@@ -37,6 +36,8 @@ export const env = createEnv({
|
||||
NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL,
|
||||
NEXT_PUBLIC_OPEN_SIGNUP: process.env.NEXT_PUBLIC_OPEN_SIGNUP,
|
||||
NEXT_PUBLIC_EMAIL_R2_DOMAIN: process.env.NEXT_PUBLIC_EMAIL_R2_DOMAIN,
|
||||
NEXT_PUBLIC_ENABLE_SUBDOMAIN_APPLY:
|
||||
process.env.NEXT_PUBLIC_ENABLE_SUBDOMAIN_APPLY,
|
||||
SCREENSHOTONE_BASE_URL: process.env.SCREENSHOTONE_BASE_URL,
|
||||
GITHUB_TOKEN: process.env.GITHUB_TOKEN,
|
||||
LinuxDo_CLIENT_ID: process.env.LinuxDo_CLIENT_ID,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use server";
|
||||
|
||||
import { auth } from "@/auth";
|
||||
import { UserRole } from "@prisma/client";
|
||||
|
||||
import { prisma } from "@/lib/db";
|
||||
@@ -25,7 +24,7 @@ export type UserRecordFormData = {
|
||||
tags: string;
|
||||
created_on?: string;
|
||||
modified_on?: string;
|
||||
active: number;
|
||||
active: number; // 0: inactive, 1: active, 2: pending
|
||||
};
|
||||
|
||||
export async function createUserRecord(
|
||||
@@ -89,9 +88,15 @@ export async function getUserRecords(
|
||||
role === "USER"
|
||||
? {
|
||||
userId,
|
||||
// active,
|
||||
active: {
|
||||
not: 2,
|
||||
},
|
||||
}
|
||||
: {};
|
||||
: {
|
||||
active: {
|
||||
not: 2,
|
||||
},
|
||||
};
|
||||
const [total, list] = await prisma.$transaction([
|
||||
prisma.userRecord.count({
|
||||
where: option,
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
@@ -18,6 +18,7 @@ export type SiteConfig = {
|
||||
};
|
||||
openSignup: boolean;
|
||||
emailR2Domain: string;
|
||||
enableSubdomainApply: boolean;
|
||||
};
|
||||
|
||||
export type NavItem = {
|
||||
|
||||
Reference in New Issue
Block a user