From 3441ecd2bbfde1db8550042cce674dfb19f66607 Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Wed, 30 Aug 2023 18:29:03 +0800 Subject: [PATCH] upload email checking --- src/pages/authentication/auth-forms/AuthLoginCustom.js | 10 +++++++++- .../authentication/auth-forms/BusCustomFormWizard.js | 5 +++-- .../authentication/auth-forms/CustomFormWizard.js | 9 +++++---- src/routes/index.js | 4 ++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/pages/authentication/auth-forms/AuthLoginCustom.js b/src/pages/authentication/auth-forms/AuthLoginCustom.js index 72068fa..5fcd3f7 100644 --- a/src/pages/authentication/auth-forms/AuthLoginCustom.js +++ b/src/pages/authentication/auth-forms/AuthLoginCustom.js @@ -97,7 +97,7 @@ const AuthLoginCustom = () => { submit: null }), validationSchema:yup.object().shape({ - username: yup.string().min(8,'用戶名稱最少8位').required('請輸入用戶名稱'), + username: yup.string().min(6,'用戶名稱最少6位').required('請輸入用戶名稱'), password: yup.string().min(8,'請輸入最少8位密碼').required('請輸入密碼') .matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母') .matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母') @@ -176,6 +176,14 @@ const AuthLoginCustom = () => { value={formik.values.username} error={Boolean(formik.touched.username && formik.errors.username)} onBlur={formik.handleBlur} + inputProps={{ + maxLength: 20, + onKeyDown: (e) => { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} /> {formik.touched.username && formik.errors.username && ( diff --git a/src/pages/authentication/auth-forms/BusCustomFormWizard.js b/src/pages/authentication/auth-forms/BusCustomFormWizard.js index acea3f7..ceaf032 100644 --- a/src/pages/authentication/auth-forms/BusCustomFormWizard.js +++ b/src/pages/authentication/auth-forms/BusCustomFormWizard.js @@ -91,6 +91,7 @@ const BusCustomFormWizard = (props) => { }, []); const checkDataField = (data)=> { + // console.log(data.brExpiryDate) if (data.username !==""&& data.password !==""&& data.confirmPassword !==""&& @@ -165,7 +166,7 @@ const BusCustomFormWizard = (props) => { const _onSubmit = () => { values.address4 = selectedAddress4 values.address5 = selectedAddress5 - console.log(values) + // console.log(values) const busUserAddress = { "addressLine1":"", "addressLine2":"", @@ -290,7 +291,7 @@ const BusCustomFormWizard = (props) => { brNo:'', }), validationSchema:yup.object().shape({ - username: yup.string().min(8,"用戶名稱最少8位").required('請輸入用戶名稱'), + username: yup.string().min(6,'用戶名稱最少6位').required('請輸入用戶名稱'), password: yup.string().min(8,'請輸入最少8位密碼').required('請輸入密碼') .matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母') .matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母') diff --git a/src/pages/authentication/auth-forms/CustomFormWizard.js b/src/pages/authentication/auth-forms/CustomFormWizard.js index 79d08d8..018145b 100644 --- a/src/pages/authentication/auth-forms/CustomFormWizard.js +++ b/src/pages/authentication/auth-forms/CustomFormWizard.js @@ -275,9 +275,10 @@ const CustomFormWizard = (props) => { } function handleEmail(email) { - var reg = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/; - var result = reg.test(email); - + var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; + // var result = reg.test(email); + var result = email.match(validRegex); + console.log("test1: "+result) if (result == false) { return false; } @@ -306,7 +307,7 @@ const CustomFormWizard = (props) => { idDocType:selectedIdDocType }), validationSchema:yup.object().shape({ - username: yup.string().min(8,"用戶名稱最少8位").required('請輸入用戶名稱'), + username: yup.string().min(6,'用戶名稱最少6位').required('請輸入用戶名稱'), password: yup.string().min(8,'請輸入最少8位密碼').required('請輸入密碼') .matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母') .matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母') diff --git a/src/routes/index.js b/src/routes/index.js index 5e044c4..81811b0 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -2,7 +2,7 @@ import LoginRoutes from './LoginRoutes' import MainRoutes from './MainRoutes' import {useRoutes} from 'react-router-dom' -import {isUserLoggedIn} from "utils/Utils"; +import {isUserLoggedIn,isAdminLoggedIn} from "utils/Utils"; import {Navigate} from "react-router"; import { setupAxiosInterceptors, @@ -33,7 +33,7 @@ export default function ThemeRoutes() { ] }, isUserLoggedIn() ? MainRoutes : LoginRoutes, - isUserLoggedIn() ? SettingRoutes : LoginRoutes, + isUserLoggedIn()&&isAdminLoggedIn() ? SettingRoutes : LoginRoutes, !isUserLoggedIn()?{ path: '*', element: