mirror of
https://github.com/outline/outline.git
synced 2026-01-05 18:49:53 -06:00
fix: Client and server validation differ for subdomains (#9468)
* fix: Client and server validation differ for subdomains * Validation message * Lower min subdomain length to 2
This commit is contained in:
@@ -10,6 +10,7 @@ import { ThemeProvider, useTheme } from "styled-components";
|
||||
import { buildDarkTheme, buildLightTheme } from "@shared/styles/theme";
|
||||
import { CustomTheme, TOCPosition, TeamPreference } from "@shared/types";
|
||||
import { getBaseDomain } from "@shared/utils/domains";
|
||||
import { TeamValidation } from "@shared/validations";
|
||||
import Button from "~/components/Button";
|
||||
import ButtonLink from "~/components/ButtonLink";
|
||||
import DefaultCollectionInputSelect from "~/components/DefaultCollectionInputSelect";
|
||||
@@ -322,8 +323,12 @@ function Details() {
|
||||
value={subdomain || ""}
|
||||
onChange={handleSubdomainChange}
|
||||
autoComplete="off"
|
||||
minLength={4}
|
||||
maxLength={32}
|
||||
minLength={TeamValidation.minSubdomainLength}
|
||||
maxLength={
|
||||
isCloudHosted
|
||||
? TeamValidation.maxSubdomainLength
|
||||
: TeamValidation.maxSubdomainSelfHostedLength
|
||||
}
|
||||
/>
|
||||
</SettingRow>
|
||||
<SettingRow
|
||||
|
||||
@@ -90,10 +90,14 @@ class Team extends ParanoidModel<
|
||||
@IsLowercase
|
||||
@Unique
|
||||
@Length({
|
||||
min: 2,
|
||||
max: env.isCloudHosted ? 32 : 255,
|
||||
msg: `subdomain must be between 2 and ${
|
||||
env.isCloudHosted ? 32 : 255
|
||||
min: TeamValidation.minSubdomainLength,
|
||||
max: env.isCloudHosted
|
||||
? TeamValidation.maxSubdomainLength
|
||||
: TeamValidation.maxSubdomainSelfHostedLength,
|
||||
msg: `subdomain must be between ${TeamValidation.minSubdomainLength} and ${
|
||||
env.isCloudHosted
|
||||
? TeamValidation.maxSubdomainLength
|
||||
: TeamValidation.maxSubdomainSelfHostedLength
|
||||
} characters`,
|
||||
})
|
||||
@Is({
|
||||
|
||||
@@ -98,6 +98,15 @@ export const TeamValidation = {
|
||||
|
||||
/** The maximum length of the team description */
|
||||
maxDescriptionLength: 1000,
|
||||
|
||||
/** The minimum length of the team subdomain */
|
||||
minSubdomainLength: 2,
|
||||
|
||||
/** The maximum length of the team subdomain for cloud */
|
||||
maxSubdomainLength: 32,
|
||||
|
||||
/** The maximum length of the team subdomain for self-hosted */
|
||||
maxSubdomainSelfHostedLength: 255,
|
||||
};
|
||||
|
||||
export const UserValidation = {
|
||||
|
||||
Reference in New Issue
Block a user