Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix: password maxlength remove

shuaib608ae6faf75
diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml
index 37ed2be2..7b1d8b18 100644
--- a/i18n/en_US.yaml
+++ b/i18n/en_US.yaml
@@ -1263,12 +1263,14 @@ ui:
site_name:
label: Site name
msg: Site name cannot be empty.
+ msg_max_length: Site name must be at maximum 30 characters in length.
site_url:
label: Site URL
text: The address of your site.
msg:
empty: Site URL cannot be empty.
incorrect: Site URL incorrect format.
+ max_length: Site URL must be at maximum 512 characters in length.
contact_email:
label: Contact email
text: Email address of key contact responsible for this site.
@@ -1283,12 +1285,15 @@ ui:
label: Name
msg: Name cannot be empty.
character: 'Must use the character set "a-z", "0-9", " - . _"'
+ msg_max_length: Name must be at maximum 30 characters in length.
admin_password:
label: Password
text: >-
You will need this password to log in. Please store it in a secure
location.
msg: Password cannot be empty.
+ msg_min_length: Password must be at least 8 characters in length.
+ msg_max_length: Password must be at maximum 32 characters in length.
admin_email:
label: Email
text: You will need this email to log in.
diff --git a/ui/src/components/Editor/toolItem.tsx b/ui/src/components/Editor/toolItem.tsx
index cba3a622..2af40682 100644
--- a/ui/src/components/Editor/toolItem.tsx
+++ b/ui/src/components/Editor/toolItem.tsx
@@ -1,5 +1,5 @@
import { FC, useContext, useEffect } from 'react';
-import { Dropdown, OverlayTrigger, Tooltip, Button } from 'react-bootstrap';
+import { Dropdown, Button } from 'react-bootstrap';
import { EditorContext } from './EditorContext';
@@ -49,28 +49,27 @@ const ToolItem: FC<IProps> = (props) => {
}, []);
const btnRender = () => (
- <OverlayTrigger placement="bottom" overlay={<Tooltip>{tip}</Tooltip>}>
- <Button
- variant="link"
- className={`p-0 b-0 btn-no-border toolbar icon-${label} ${
- disable ? 'disabled' : ''
- } `}
- disabled={disable}
- tabIndex={-1}
- onClick={(e) => {
- e.preventDefault();
- if (typeof onClick === 'function') {
- onClick();
- }
- }}
- onBlur={(e) => {
- e.preventDefault();
- if (typeof onBlur === 'function') {
- onBlur();
- }
- }}
- />
- </OverlayTrigger>
+ <Button
+ variant="link"
+ title={tip}
+ className={`p-0 b-0 btn-no-border toolbar icon-${label} ${
+ disable ? 'disabled' : ''
+ } `}
+ disabled={disable}
+ tabIndex={-1}
+ onClick={(e) => {
+ e.preventDefault();
+ if (typeof onClick === 'function') {
+ onClick();
+ }
+ }}
+ onBlur={(e) => {
+ e.preventDefault();
+ if (typeof onBlur === 'function') {
+ onBlur();
+ }
+ }}
+ />
);
if (!context) {
diff --git a/ui/src/pages/Install/components/FourthStep/index.tsx b/ui/src/pages/Install/components/FourthStep/index.tsx
index c8d0eb2c..ac4e441a 100644
--- a/ui/src/pages/Install/components/FourthStep/index.tsx
+++ b/ui/src/pages/Install/components/FourthStep/index.tsx
@@ -28,6 +28,15 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
};
}
+ if (site_name.value && site_name.value.length > 30) {
+ bol = false;
+ data.site_url = {
+ value: site_name.value,
+ isInvalid: true,
+ errorMsg: t('site_name.msg_max_length'),
+ };
+ }
+
if (!site_url.value) {
bol = false;
data.site_url = {
@@ -36,6 +45,7 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
errorMsg: t('site_name.msg.empty'),
};
}
+
const reg = /^(http|https):\/\//g;
if (site_url.value && !site_url.value.match(reg)) {
bol = false;
@@ -44,6 +54,13 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
isInvalid: true,
errorMsg: t('site_url.msg.incorrect'),
};
+ } else if (site_url.value.length > 512) {
+ bol = false;
+ data.site_url = {
+ value: site_url.value,
+ isInvalid: true,
+ errorMsg: t('site_url.msg.max_length'),
+ };
}
if (!contact_email.value) {
@@ -78,6 +95,13 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
isInvalid: true,
errorMsg: t('admin_name.character'),
};
+ } else if (data.name.value.length > 30) {
+ bol = false;
+ data.name = {
+ value: data.name.value,
+ isInvalid: true,
+ errorMsg: t('admin_name.msg_max_length'),
+ };
}
if (!password.value) {
@@ -89,6 +113,24 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
};
}
+ if (password.value && password.value.length < 4) {
+ bol = false;
+ data.password = {
+ value: data.password.value,
+ isInvalid: true,
+ errorMsg: t('admin_password.msg_min_length'),
+ };
+ }
+
+ if (password.value && password.value.length > 32) {
+ bol = false;
+ data.password = {
+ value: data.password.value,
+ isInvalid: true,
+ errorMsg: t('admin_password.msg_max_length'),
+ };
+ }
+
if (!email.value) {
bol = false;
data.email = {
@@ -132,7 +174,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
required
value={data.site_name.value}
isInvalid={data.site_name.isInvalid}
- maxLength={30}
onChange={(e) => {
changeCallback({
site_name: {
@@ -153,7 +194,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
required
value={data.site_url.value}
isInvalid={data.site_url.isInvalid}
- maxLength={512}
onChange={(e) => {
changeCallback({
site_url: {
@@ -220,7 +260,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
required
value={data.name.value}
isInvalid={data.name.isInvalid}
- maxLength={30}
onChange={(e) => {
changeCallback({
name: {
@@ -241,7 +280,6 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
<Form.Control
required
type="password"
- maxLength={32}
value={data.password.value}
isInvalid={data.password.isInvalid}
onChange={(e) => {
diff --git a/ui/src/pages/Install/index.tsx b/ui/src/pages/Install/index.tsx
index 4262e135..0f78e23c 100644
--- a/ui/src/pages/Install/index.tsx
+++ b/ui/src/pages/Install/index.tsx
@@ -23,7 +23,7 @@ import {
const Index: FC = () => {
const { t } = useTranslation('translation', { keyPrefix: 'install' });
- const [step, setStep] = useState(1);
+ const [step, setStep] = useState(4);
const [loading, setLoading] = useState(true);
const [errorData, setErrorData] = useState<{ [propName: string]: any }>({
msg: '',
diff --git a/ui/src/pages/Users/Login/index.tsx b/ui/src/pages/Users/Login/index.tsx
index 81980290..17357251 100644
--- a/ui/src/pages/Users/Login/index.tsx
+++ b/ui/src/pages/Users/Login/index.tsx
@@ -187,7 +187,6 @@ const Index: React.FC = () => {
tabIndex={1}
type="password"
// value={formData.pass.value}
- maxLength={32}
isInvalid={formData.pass.isInvalid}
onChange={(e) =>
handleChange({
diff --git a/ui/src/pages/Users/PasswordReset/index.tsx b/ui/src/pages/Users/PasswordReset/index.tsx
index 3e975937..0a4a5c03 100644
--- a/ui/src/pages/Users/PasswordReset/index.tsx
+++ b/ui/src/pages/Users/PasswordReset/index.tsx
@@ -127,7 +127,6 @@ const Index: React.FC = () => {
autoComplete="off"
required
type="password"
- maxLength={32}
isInvalid={formData.pass.isInvalid}
onChange={(e) => {
handleChange({
@@ -150,7 +149,6 @@ const Index: React.FC = () => {
autoComplete="off"
required
type="password"
- maxLength={32}
isInvalid={formData.passSecond.isInvalid}
onChange={(e) => {
handleChange({
diff --git a/ui/src/pages/Users/Register/components/SignUpForm/index.tsx b/ui/src/pages/Users/Register/components/SignUpForm/index.tsx
index a77508db..e169fa3d 100644
--- a/ui/src/pages/Users/Register/components/SignUpForm/index.tsx
+++ b/ui/src/pages/Users/Register/components/SignUpForm/index.tsx
@@ -184,7 +184,6 @@ const Index: React.FC<Props> = ({ callback }) => {
autoComplete="off"
required
type="password"
- maxLength={32}
isInvalid={formData.pass.isInvalid}
value={formData.pass.value}
onChange={(e) =>
diff --git a/ui/src/pages/Users/Settings/Account/components/ModifyEmail/index.tsx b/ui/src/pages/Users/Settings/Account/components/ModifyEmail/index.tsx
index 3c5fdee1..528d53b5 100644
--- a/ui/src/pages/Users/Settings/Account/components/ModifyEmail/index.tsx
+++ b/ui/src/pages/Users/Settings/Account/components/ModifyEmail/index.tsx
@@ -158,7 +158,6 @@ const Index: FC = () => {
autoComplete="new-password"
required
type="password"
- maxLength={32}
isInvalid={formData.pass.isInvalid}
onChange={(e) =>
handleChange({
diff --git a/ui/src/pages/Users/Settings/Account/components/ModifyPass/index.tsx b/ui/src/pages/Users/Settings/Account/components/ModifyPass/index.tsx
index 3caf7c76..8bef5f1f 100644
--- a/ui/src/pages/Users/Settings/Account/components/ModifyPass/index.tsx
+++ b/ui/src/pages/Users/Settings/Account/components/ModifyPass/index.tsx
@@ -185,7 +185,6 @@ const Index: FC = () => {
autoComplete="off"
required
type="password"
- maxLength={32}
isInvalid={formData.pass.isInvalid}
onChange={(e) =>
handleChange({
@@ -208,7 +207,6 @@ const Index: FC = () => {
autoComplete="off"
required
type="password"
- maxLength={32}
isInvalid={formData.pass2.isInvalid}
onChange={(e) =>
handleChange({