@@ -97,7 +97,7 @@ const AuthLoginCustom = () => { | |||||
submit: null | submit: null | ||||
}), | }), | ||||
validationSchema:yup.object().shape({ | 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('請輸入密碼') | password: yup.string().min(8,'請輸入最少8位密碼').required('請輸入密碼') | ||||
.matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母') | .matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母') | ||||
.matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母') | .matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母') | ||||
@@ -176,6 +176,14 @@ const AuthLoginCustom = () => { | |||||
value={formik.values.username} | value={formik.values.username} | ||||
error={Boolean(formik.touched.username && formik.errors.username)} | error={Boolean(formik.touched.username && formik.errors.username)} | ||||
onBlur={formik.handleBlur} | onBlur={formik.handleBlur} | ||||
inputProps={{ | |||||
maxLength: 20, | |||||
onKeyDown: (e) => { | |||||
if (e.key === 'Enter') { | |||||
e.preventDefault(); | |||||
} | |||||
}, | |||||
}} | |||||
/> | /> | ||||
{formik.touched.username && formik.errors.username && ( | {formik.touched.username && formik.errors.username && ( | ||||
<FormHelperText error id="standard-weight-helper-text-username-login"> | <FormHelperText error id="standard-weight-helper-text-username-login"> | ||||
@@ -91,6 +91,7 @@ const BusCustomFormWizard = (props) => { | |||||
}, []); | }, []); | ||||
const checkDataField = (data)=> { | const checkDataField = (data)=> { | ||||
// console.log(data.brExpiryDate) | |||||
if (data.username !==""&& | if (data.username !==""&& | ||||
data.password !==""&& | data.password !==""&& | ||||
data.confirmPassword !==""&& | data.confirmPassword !==""&& | ||||
@@ -165,7 +166,7 @@ const BusCustomFormWizard = (props) => { | |||||
const _onSubmit = () => { | const _onSubmit = () => { | ||||
values.address4 = selectedAddress4 | values.address4 = selectedAddress4 | ||||
values.address5 = selectedAddress5 | values.address5 = selectedAddress5 | ||||
console.log(values) | |||||
// console.log(values) | |||||
const busUserAddress = { | const busUserAddress = { | ||||
"addressLine1":"", | "addressLine1":"", | ||||
"addressLine2":"", | "addressLine2":"", | ||||
@@ -290,7 +291,7 @@ const BusCustomFormWizard = (props) => { | |||||
brNo:'', | brNo:'', | ||||
}), | }), | ||||
validationSchema:yup.object().shape({ | 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('請輸入密碼') | password: yup.string().min(8,'請輸入最少8位密碼').required('請輸入密碼') | ||||
.matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母') | .matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母') | ||||
.matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母') | .matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母') | ||||
@@ -275,9 +275,10 @@ const CustomFormWizard = (props) => { | |||||
} | } | ||||
function handleEmail(email) { | 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) { | if (result == false) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -306,7 +307,7 @@ const CustomFormWizard = (props) => { | |||||
idDocType:selectedIdDocType | idDocType:selectedIdDocType | ||||
}), | }), | ||||
validationSchema:yup.object().shape({ | 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('請輸入密碼') | password: yup.string().min(8,'請輸入最少8位密碼').required('請輸入密碼') | ||||
.matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母') | .matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母') | ||||
.matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母') | .matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母') | ||||
@@ -2,7 +2,7 @@ | |||||
import LoginRoutes from './LoginRoutes' | import LoginRoutes from './LoginRoutes' | ||||
import MainRoutes from './MainRoutes' | import MainRoutes from './MainRoutes' | ||||
import {useRoutes} from 'react-router-dom' | import {useRoutes} from 'react-router-dom' | ||||
import {isUserLoggedIn} from "utils/Utils"; | |||||
import {isUserLoggedIn,isAdminLoggedIn} from "utils/Utils"; | |||||
import {Navigate} from "react-router"; | import {Navigate} from "react-router"; | ||||
import { | import { | ||||
setupAxiosInterceptors, | setupAxiosInterceptors, | ||||
@@ -33,7 +33,7 @@ export default function ThemeRoutes() { | |||||
] | ] | ||||
}, | }, | ||||
isUserLoggedIn() ? MainRoutes : LoginRoutes, | isUserLoggedIn() ? MainRoutes : LoginRoutes, | ||||
isUserLoggedIn() ? SettingRoutes : LoginRoutes, | |||||
isUserLoggedIn()&&isAdminLoggedIn() ? SettingRoutes : LoginRoutes, | |||||
!isUserLoggedIn()?{ | !isUserLoggedIn()?{ | ||||
path: '*', | path: '*', | ||||
element: <Navigate to="/login"/> | element: <Navigate to="/login"/> | ||||