From c4a7f92639db0986332036b5e13be7746cce9794 Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Thu, 7 Sep 2023 11:38:26 +0800 Subject: [PATCH] update jwt respon with type, chName and enName --- .../Header/HeaderContent/Profile/index.js | 4 +- src/layout/MainLayout/Header/index.js | 6 +-- src/pages/authentication/AuthWrapper.js | 6 ++- .../authentication/auth-forms/AuthLogin.js | 4 +- .../auth-forms/AuthLoginCustom.js | 51 +++++++++---------- .../auth-forms/BusCustomFormWizard.js | 5 +- .../auth-forms/CustomFormWizard.js | 6 ++- src/pages/gldDashboard/index.js | 41 +++++++++++++++ .../UserInformationCard.js | 6 +-- .../pnspsUserSearchPage/UserSearchForm.js | 6 +-- .../UserSearchForm_Individual.js | 6 +-- .../UserSearchForm_Organization.js | 6 +-- src/pages/publicDashboard/index.js | 40 +++++++++++++++ src/routes/GLDUserRoutes.js | 32 ++++++++++++ src/routes/MainRoutes.js | 14 ----- src/routes/PublicUserRoutes.js | 32 ++++++++++++ src/routes/index.js | 13 ++++- src/utils/Utils.js | 17 ++++++- 18 files changed, 229 insertions(+), 66 deletions(-) create mode 100644 src/pages/gldDashboard/index.js create mode 100644 src/pages/publicDashboard/index.js create mode 100644 src/routes/GLDUserRoutes.js create mode 100644 src/routes/PublicUserRoutes.js diff --git a/src/layout/MainLayout/Header/HeaderContent/Profile/index.js b/src/layout/MainLayout/Header/HeaderContent/Profile/index.js index 9f2d6f0..3bbfed0 100644 --- a/src/layout/MainLayout/Header/HeaderContent/Profile/index.js +++ b/src/layout/MainLayout/Header/HeaderContent/Profile/index.js @@ -152,9 +152,9 @@ const Profile = () => { 我的帳戶 - {userData == null ? "" : userData.fullName} + {userData == null ? "" : userData.fullenName} - {/* {userData == null ? "" : userData.fullName} */} + {/* {userData == null ? "" : userData.fullenName} */} diff --git a/src/layout/MainLayout/Header/index.js b/src/layout/MainLayout/Header/index.js index 9e46add..a1a9b63 100644 --- a/src/layout/MainLayout/Header/index.js +++ b/src/layout/MainLayout/Header/index.js @@ -41,7 +41,7 @@ import AdminLogo from 'components/AdminLogo'; import MobileLogo from 'components/MobileLogo'; import Profile from './HeaderContent/Profile'; import "assets/style/navbarStyles.css"; -import {isUserLoggedIn,isAdminLoggedIn} from "utils/Utils"; +import {isUserLoggedIn,isGLDLoggedIn} from "utils/Utils"; import { handleLogoutFunction } from 'auth/index'; // assets @@ -71,7 +71,7 @@ function Header(props) { }; const loginContent = ( - isAdminLoggedIn() ? + isGLDLoggedIn() ?
  • Dashboard @@ -180,7 +180,7 @@ function Header(props) { - {isAdminLoggedIn() + {isGLDLoggedIn() ? ( justifyContent="space-between" alignItems="center" spacing={2}> - + 香港特別行政區政府 憲報 { setPosts(response.data); const userData = { id: response.data.id, - fullName: response.data.name, + fullenName: response.data.name, + fullchName: response.data.chName, email: response.data.email, + type: response.data.type, role: response.data.role, abilities: response.data.abilities, //avatar: require('src/assets/images/users/avatar-3.png').default, diff --git a/src/pages/authentication/auth-forms/AuthLoginCustom.js b/src/pages/authentication/auth-forms/AuthLoginCustom.js index 15d4288..ae54206 100644 --- a/src/pages/authentication/auth-forms/AuthLoginCustom.js +++ b/src/pages/authentication/auth-forms/AuthLoginCustom.js @@ -55,12 +55,8 @@ const AuthLoginCustom = () => { // let [posts, setPosts] = useState([]); const [isValid, setisValid] = useState(false); - // const [isSuccess, setSuccess] = useState(); - // const [isSumitting, setSumitting] = useState(); const [open, setOpen] = React.useState(false); - // useEffect(() => { - // // console.log("POST: " + posts.accessToken); - // },[posts]); + const [isButtonDisabled, setIsButtonDisabled] = useState(true); const handleMouseDownPassword = (event) => { event.preventDefault(); @@ -72,10 +68,13 @@ const AuthLoginCustom = () => { useJwt .login({username: values.username, password: values.password}) .then((response) => { + console.log("123") const userData = { id: response.data.id, - fullName: response.data.name, + fullenName: response.data.name, + fullchName: response.data.chName, email: response.data.email, + type: response.data.type, role: response.data.role, abilities: response.data.abilities, //avatar: require('src/assets/images/users/avatar-3.png').default, @@ -90,6 +89,7 @@ const AuthLoginCustom = () => { // setSuccess(false) setOpen(true) console.error(error) + console.log("321") }); }else{ setOpen(true) @@ -121,9 +121,11 @@ const AuthLoginCustom = () => { ) { setisValid(true) + setIsButtonDisabled(false); return isValid }else{ setisValid(false) + setIsButtonDisabled(true); return isValid } }; @@ -134,27 +136,22 @@ const AuthLoginCustom = () => { var lowerCase = /[a-z]/g; var upperCase = /[A-Z]/g; var numbers = /[0-9]/g; + var symbol = /^(?=.*[!@#%&])/; if (!new_pass.match(lowerCase)) { return false; } else if (!new_pass.match(upperCase)) { return false; } else if (!new_pass.match(numbers)) { return false; - } else if (new_pass.length < 8) { + } else if (!new_pass.match(symbol)) { return false; + } else if (new_pass.length < 8) { + return false; } else { return true; } } - // function handle6Digi(value) { - // if (value.length < 6) { - // return false; - // } else { - // return true; - // } - // } - const handleClose = () => { setOpen(false); }; @@ -235,15 +232,23 @@ const AuthLoginCustom = () => { - - + 忘記密碼? @@ -252,7 +257,7 @@ const AuthLoginCustom = () => { - + @@ -265,14 +270,6 @@ const AuthLoginCustom = () => { - {/* */} - {/* */} - {/* Login with*/} - {/* */} - {/**/} - {/**/} - {/* */} - {/* */} diff --git a/src/pages/authentication/auth-forms/BusCustomFormWizard.js b/src/pages/authentication/auth-forms/BusCustomFormWizard.js index bca0437..d5046c6 100644 --- a/src/pages/authentication/auth-forms/BusCustomFormWizard.js +++ b/src/pages/authentication/auth-forms/BusCustomFormWizard.js @@ -313,14 +313,17 @@ const BusCustomFormWizard = (props) => { var lowerCase = /[a-z]/g; var upperCase = /[A-Z]/g; var numbers = /[0-9]/g; + var symbol = /^(?=.*[!@#%&])/; if (!new_pass.match(lowerCase)) { return false; } else if (!new_pass.match(upperCase)) { return false; } else if (!new_pass.match(numbers)) { return false; - } else if (new_pass.length < 8) { + } else if (!new_pass.match(symbol)) { return false; + } else if (new_pass.length < 8) { + return false; } else { return true; } diff --git a/src/pages/authentication/auth-forms/CustomFormWizard.js b/src/pages/authentication/auth-forms/CustomFormWizard.js index e44c7f4..e66b921 100644 --- a/src/pages/authentication/auth-forms/CustomFormWizard.js +++ b/src/pages/authentication/auth-forms/CustomFormWizard.js @@ -334,12 +334,15 @@ const CustomFormWizard = (props) => { var lowerCase = /[a-z]/g; var upperCase = /[A-Z]/g; var numbers = /[0-9]/g; + var symbol = /^(?=.*[!@#%&])/; if (!new_pass.match(lowerCase)) { return false; } else if (!new_pass.match(upperCase)) { return false; } else if (!new_pass.match(numbers)) { return false; + } else if (!new_pass.match(symbol)) { + return false; } else if (new_pass.length < 8) { return false; } else { @@ -849,6 +852,7 @@ const CustomFormWizard = (props) => { options={address5ComboList} onChange={(event, newValue) => { setSelectedAddress5(newValue); + // if() }} sx={{"& .MuiInputBase-root": { height: "41px" },"#address5-combo":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} @@ -1085,7 +1089,7 @@ const CustomFormWizard = (props) => { 身份證明文件 請上傳你的 有效身份證明文件 的數碼檔案,以驗證你的身份。 - 如: 香港身份證; 護照; 中國內地身份證等 + 如: 香港身份證; 護照; 中國內地身份證; 專業執業証書等