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: username verification format #181

shuaibdaf254af17c
diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml
index 89d480af..26b134b2 100644
--- a/i18n/en_US.yaml
+++ b/i18n/en_US.yaml
@@ -618,6 +618,7 @@ ui:
msg:
empty: Name cannot be empty.
range: Name up to 30 characters.
+ character: 'Must use the character set "a-z", "0-9", " - . _"'
email:
label: Email
msg:
@@ -981,6 +982,7 @@ ui:
admin_name:
label: Name
msg: Name cannot be empty.
+ character: 'Must use the character set "a-z", "0-9", " - . _"'
admin_password:
label: Password
text: >-
diff --git a/ui/src/pages/Install/components/FourthStep/index.tsx b/ui/src/pages/Install/components/FourthStep/index.tsx
index 0f7d7b88..beaf9e66 100644
--- a/ui/src/pages/Install/components/FourthStep/index.tsx
+++ b/ui/src/pages/Install/components/FourthStep/index.tsx
@@ -71,6 +71,13 @@ const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
isInvalid: true,
errorMsg: t('admin_name.msg'),
};
+ } else if (/[^a-z0-9\-._]/.test(name.value)) {
+ bol = false;
+ data.name = {
+ value: name.value,
+ isInvalid: true,
+ errorMsg: t('admin_name.character'),
+ };
}
if (!password.value) {
diff --git a/ui/src/pages/Install/index.tsx b/ui/src/pages/Install/index.tsx
index 70674def..46d3cfc7 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/Register/components/SignUpForm/index.tsx b/ui/src/pages/Users/Register/components/SignUpForm/index.tsx
index ea856a4f..56c51f52 100644
--- a/ui/src/pages/Users/Register/components/SignUpForm/index.tsx
+++ b/ui/src/pages/Users/Register/components/SignUpForm/index.tsx
@@ -70,6 +70,13 @@ const Index: React.FC<Props> = ({ callback }) => {
isInvalid: true,
errorMsg: t('name.msg.empty'),
};
+ } else if (/[^a-z0-9\-._]/.test(name.value)) {
+ bol = false;
+ formData.name = {
+ value: name.value,
+ isInvalid: true,
+ errorMsg: t('name.msg.character'),
+ };
} else if ([...name.value].length > 30) {
bol = false;
formData.name = {