From bd40598a1ddc7a10667338223f71779af1521635 Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Thu, 6 Jun 2024 18:52:07 +0800 Subject: [PATCH] update password log --- .../ResetPasswordSuccess.js | 122 +++++ src/pages/User/ChangePasswordPage/index.js | 459 ++++++++++++++++++ .../authentication/auth-forms/AuthLogin.js | 1 + .../auth-forms/AuthLoginCustom.js | 1 + src/pages/iAmSmart/AuthCallback/index.js | 1 + .../iAmSmart/DirectLoginCallback/index.js | 1 + src/routes/GLDUserRoutes.js | 310 ++++++------ src/routes/PublicUserRoutes.js | 24 +- src/routes/index.js | 20 +- src/translations/zh-CN.json | 2 +- src/translations/zh-HK.json | 2 +- src/utils/Utils.js | 24 + 12 files changed, 800 insertions(+), 167 deletions(-) create mode 100644 src/pages/User/ChangePasswordPage/ResetPasswordSuccess.js create mode 100644 src/pages/User/ChangePasswordPage/index.js diff --git a/src/pages/User/ChangePasswordPage/ResetPasswordSuccess.js b/src/pages/User/ChangePasswordPage/ResetPasswordSuccess.js new file mode 100644 index 0000000..2b81f48 --- /dev/null +++ b/src/pages/User/ChangePasswordPage/ResetPasswordSuccess.js @@ -0,0 +1,122 @@ +// import { useFormik } from 'formik'; +// import * as yup from 'yup'; +import * as React from "react"; +// import * as HttpUtils from "utils/HttpUtils"; +// import * as UrlUtils from "utils/ApiPathConst"; +// import { useNavigate } from "react-router-dom"; +// import { useDispatch } from "react-redux"; +// import { handleLogoutFunction, handleLogin} from 'auth/index'; +// import useJwt from "auth/jwt/useJwt"; + +import { + Grid, + Typography, + Button, + // RadioGroup, + // Dialog, DialogTitle, DialogContent, DialogActions, + Stack, + // InputLabel, + // OutlinedInput, + // FormHelperText, + // TextField, + // IconButton, InputAdornment, + // Box, + // FormControl +} from '@mui/material'; +import Loadable from 'components/Loadable'; +const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); +import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' +// import ForwardIcon from '@mui/icons-material/Forward'; +import MainCard from 'components/MainCard'; +// import {PNSPS_LONG_BUTTON_THEME} from "themes/buttonConst"; +// import {ThemeProvider} from "@emotion/react"; +import {FormattedMessage, + // useIntl +} from "react-intl"; +// import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons'; +// import axios from 'axios'; +import { + // useParams, + Link +} from 'react-router-dom'; +import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline'; + +// import LocaleContext from "components/I18nProvider"; + +// ==============================|| DASHBOARD - DEFAULT ||============================== // + +const ResetPasswordSuccess = () => { + + const [isLoading, setLoding] = React.useState(true); + + React.useEffect(() => { + setLoding(false) + }, []); + + const BackgroundHead = { + backgroundImage: `url(${titleBackgroundImg})`, + width: 'auto', + height: 'auto', + backgroundSize: 'contain', + backgroundRepeat: 'no-repeat', + backgroundColor: '#0C489E', + backgroundPosition: 'right' + } + + return ( + isLoading ? + + + + + + : + + +
+ + + + + +
+
+ + *': { + flexGrow: 1, + flexBasis: '50%' + } + }} + content={false} + border={false} + boxShadow + > + + + {/* */} + + + + + + + + + + + + + +
+ ); +}; + +export default ResetPasswordSuccess; \ No newline at end of file diff --git a/src/pages/User/ChangePasswordPage/index.js b/src/pages/User/ChangePasswordPage/index.js new file mode 100644 index 0000000..354abd5 --- /dev/null +++ b/src/pages/User/ChangePasswordPage/index.js @@ -0,0 +1,459 @@ +import { useFormik } from 'formik'; +import * as yup from 'yup'; +import * as React from "react"; +import * as HttpUtils from "utils/HttpUtils"; +import * as UrlUtils from "utils/ApiPathConst"; +import { useNavigate } from "react-router-dom"; +import { useDispatch } from "react-redux"; +import { handleLogoutFunction, + // handleLogin + } from 'auth/index'; +import useJwt from "auth/jwt/useJwt"; + +import { + Grid, + Typography, + Button, + // RadioGroup, + // Dialog, DialogTitle, DialogContent, DialogActions, + Stack, + InputLabel, + // OutlinedInput, + FormHelperText, + TextField, + IconButton, InputAdornment, + // Box, + // FormControl +} from '@mui/material'; +import Loadable from 'components/Loadable'; +const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); +import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' +// import ForwardIcon from '@mui/icons-material/Forward'; +import MainCard from 'components/MainCard'; +import {PNSPS_LONG_BUTTON_THEME} from "themes/buttonConst"; +import {ThemeProvider} from "@emotion/react"; +import {FormattedMessage, useIntl} from "react-intl"; +import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons'; +import axios from 'axios'; +import { useParams,Link } from 'react-router-dom'; +import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined'; +// import LocaleContext from "components/I18nProvider"; + +// ==============================|| DASHBOARD - DEFAULT ||============================== // + +const Index = () => { + const dispatch = useDispatch() + const navigate = useNavigate() + const [showPassword, setShowPassword] = React.useState(false); + const [showConfirmPassword, setshowConfirmPassword] = React.useState(false); + const [isLoading, setLoding] = React.useState(true); + const [verifyState, setVerifyState] = React.useState(null) + const [enterUseEffect, setEnterUseEffect] = React.useState(false) + const [username, setUsername] = React.useState("") + // const { setLocale } = React.useContext(LocaleContext); + + const params = useParams() + const intl = useIntl(); + + React.useEffect(() => { + console.log(params); + setEnterUseEffect(true) + }, []); + + React.useEffect(() => { + // console.log("if (enterUseEffect) handleVerify()"); + if (enterUseEffect){ + handleVerify() + } + }, [enterUseEffect]) + + const handleVerify = async () => { + console.log(params); + await axios.get(UrlUtils.GET_FORGOT_PASSWORD_VERIFY_USER_ACCOUNT, { + params: { + email: decodeURIComponent(params.email), + emailVerifyHash: decodeURIComponent(params.verifyCode) + } + }).then( + (response)=>{ + if (response.status === 200 && response.data) { + console.log(response) + setUsername(response.data.username) + setVerifyState(true) + } else { + setVerifyState(false) + } + setLoding(false) + } + ).catch(error => { + console.log(error) + setVerifyState(false) + setLoding(false) + }); + + + } + + const goLogin = async (values) =>{ + dispatch(handleLogoutFunction()); + HttpUtils.post({ + url: UrlUtils.POST_FORGOT_PASSWORD_NEW_PASSWORD, + params:{ + username: username, + newPassword: values.password + }, + onSuccess: () => { + useJwt + .login({ username: username, password: values.password }) + .then(( + // response + ) => { + // console.log(response) + navigate('/forgot/password/success'); + location.reload() + // setSumitting(false) + }) + .catch((error) => { + console.error(error) + }); + }, + onFail: (response)=>{ + console.log("Fail"); + console.log(response); + // window.location.assign("/iamsmart/loginFail"); + }, + onError:(error)=>{ + console.log(error); + // window.location.assign("/iamsmart/loginFail"); + } + }); + } + + const BackgroundHead = { + backgroundImage: `url(${titleBackgroundImg})`, + width: 'auto', + height: 'auto', + backgroundSize: 'contain', + backgroundRepeat: 'no-repeat', + backgroundColor: '#0C489E', + backgroundPosition: 'right' + } + + const handleClickShowPassword = () => { + setShowPassword(!showPassword); + }; + + const handleClickShowConfirmPassword = () => { + setshowConfirmPassword(!showConfirmPassword); + }; + + const handleMouseDownPassword = (event) => { + event.preventDefault(); + }; + + const changePassword = ( + // value + ) => { + // const temp = strengthIndicator(value); + // setLevel(strengthColorChi(temp)); + }; + + const formik = useFormik({ + enableReinitialize: true, + initialValues: { + // username: '', + password: '', + confirmPassword: '', + // emailVerifyHash: '', + }, + validationSchema: yup.object().shape({ + // emailVerifyHash: yup.string().required(intl.formatMessage({id: 'requireSecurityCode'})), + // username: yup.string().required(intl.formatMessage({id: 'requireUsername'})), + password: yup.string().min(8, intl.formatMessage({id: 'atLeast8CharPassword'})) + .required(intl.formatMessage({id: 'requirePassword'})) + .matches(/^\S*$/, { message: (intl.formatMessage({id: 'noSpacePassword'}))}) + .matches(/^(?=.*[a-z])/, { message: intl.formatMessage({id: 'atLeastOneSmallLetter'})}) + .matches(/^(?=.*[A-Z])/, { message: intl.formatMessage({id: 'atLeastOneCapLetter'})}) + .matches(/^(?=.*[0-9])/, { message: intl.formatMessage({id: 'atLeast1Number'})}) + .matches(/^(?=.*[!@#%&])/, { message: intl.formatMessage({id: 'atLeast1SpecialChar'})}), + confirmPassword: yup.string().min(8, intl.formatMessage({id: 'atLeast8CharPassword'})) + .required(intl.formatMessage({id: 'pleaseConfirmPassword'})) + .oneOf([yup.ref('password'), null], intl.formatMessage({id: 'samePassword'})), + }), + onSubmit: values => { + // console.log(values) + goLogin(values) + } + }); + + return ( + isLoading || verifyState == null ? + + + + + + : + + +
+ + + + + +
+
+ {/* + + */} + {/* + 申請公共啟事 + */} + + *': { + flexGrow: 1, + flexBasis: '50%' + } + }} + content={false} + border={false} + boxShadow + > +
+ {verifyState ? + // SUCCESS page + + + + + + + + + + + + + + + + {/* + + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + InputLabelProps={{ + shrink: true + }} + /> + + {formik.touched.emailVerifyHash && formik.errors.emailVerifyHash && ( + + {formik.errors.emailVerifyHash} + + )} + + */} + + + + + + + + + + + { + formik.handleChange(e); + changePassword(e.target.value); + }} + id="password" + type={showPassword ? 'text' : 'password'} + name="password" + label={intl.formatMessage({id: 'newPassword'}) + ":"} + placeholder={intl.formatMessage({id: 'newPassword'})} + // defaultValue={formik.values.password.trim()} + value={formik.values.password.trim()} + error={Boolean(formik.touched.password && formik.errors.password)} + onBlur={formik.handleBlur} + inputProps={{ + onKeyDown: (e) => { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + InputLabelProps={{ + shrink: true + }} + InputProps={{ + endAdornment:( + + + {showPassword ? : } + + + ) + }} + /> + + {/* + + + + + + + + + + + */} + {formik.touched.password && formik.errors.password && ( + + {formik.errors.password} + + )} + + + + + + { + formik.handleChange(e); + // changePassword(e.target.value); + }} + id="confirmPassword" + type={showConfirmPassword ? 'text' : 'password'} + name="confirmPassword" + label={intl.formatMessage({id: 'confirmPassword'}) + ":"} + placeholder={intl.formatMessage({id: 'confirmPassword'})} + // defaultValue={formik.values.confirmPassword.trim()} + value={formik.values.confirmPassword.trim()} + error={Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword)} + onBlur={formik.handleBlur} + inputProps={{ + maxLength: 50, + onKeyDown: (e) => { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + InputLabelProps={{ + shrink: true + }} + InputProps={{ + endAdornment:( + + + {showConfirmPassword ? : } + + + ) + }} + /> + + {formik.touched.confirmPassword && formik.errors.confirmPassword && ( + + {formik.errors.confirmPassword} + + )} + + + + + + + + + : + // ERROR page + + + {/* */} + + + + + + + + + + + + } +
+
+
+
+ ); +}; + +export default Index; \ No newline at end of file diff --git a/src/pages/authentication/auth-forms/AuthLogin.js b/src/pages/authentication/auth-forms/AuthLogin.js index 6dfb8d0..5f710eb 100644 --- a/src/pages/authentication/auth-forms/AuthLogin.js +++ b/src/pages/authentication/auth-forms/AuthLogin.js @@ -83,6 +83,7 @@ const AuthLogin = () => { type: response.data.type, role: response.data.role, abilities: response.data.abilities, + passwordExpiryDate: response.data.passwordExpiryDate, //avatar: require('src/assets/images/users/avatar-3.png').default, } // const abilities = response.data.abilities diff --git a/src/pages/authentication/auth-forms/AuthLoginCustom.js b/src/pages/authentication/auth-forms/AuthLoginCustom.js index 2c03f46..8421fb5 100644 --- a/src/pages/authentication/auth-forms/AuthLoginCustom.js +++ b/src/pages/authentication/auth-forms/AuthLoginCustom.js @@ -93,6 +93,7 @@ const AuthLoginCustom = () => { abilities: response.data.abilities, creditor: response.data.creditor, locale: response.data.preferLocale, + passwordExpiryDate: response.data.passwordExpiryDate, //avatar: require('src/assets/images/users/avatar-3.png').default, } const data = { ...userData, accessToken: response.data.accessToken, refreshToken: response.data.refreshToken } diff --git a/src/pages/iAmSmart/AuthCallback/index.js b/src/pages/iAmSmart/AuthCallback/index.js index d1ea104..4a9602b 100644 --- a/src/pages/iAmSmart/AuthCallback/index.js +++ b/src/pages/iAmSmart/AuthCallback/index.js @@ -45,6 +45,7 @@ const Index = () => { role: responseData.role, abilities: responseData.abilities, creditor: responseData.creditor, + passwordExpiryDate: response.data.passwordExpiryDate, //locale: responseData.preferLocale, //avatar: require('src/assets/images/users/avatar-3.png').default, } diff --git a/src/pages/iAmSmart/DirectLoginCallback/index.js b/src/pages/iAmSmart/DirectLoginCallback/index.js index 0ee31d8..8c76a2a 100644 --- a/src/pages/iAmSmart/DirectLoginCallback/index.js +++ b/src/pages/iAmSmart/DirectLoginCallback/index.js @@ -45,6 +45,7 @@ const Index = () => { role: responseData.role, abilities: responseData.abilities, creditor: responseData.creditor, + passwordExpiryDate: response.data.passwordExpiryDate, //avatar: require('src/assets/images/users/avatar-3.png').default, } const data = { ...userData, accessToken: responseData.accessToken, refreshToken: responseData.refreshToken } diff --git a/src/routes/GLDUserRoutes.js b/src/routes/GLDUserRoutes.js index 12bc095..b446b9f 100644 --- a/src/routes/GLDUserRoutes.js +++ b/src/routes/GLDUserRoutes.js @@ -5,7 +5,7 @@ import Loadable from 'components/Loadable'; // import MainLayout from 'layout/MainLayout'; const MainLayout = Loadable(lazy(() => import('layout/MainLayout'))); import {isGranted, isGrantedAny} from "auth/utils"; - +import { isPasswordExpiry } from "utils/Utils"; // render - dashboard const DashboardDefault = Loadable(lazy(() => import('pages/Dashboard/GLD'))); const ApplicationDetail = Loadable(lazy(() => import('pages/PublicNotice/Details_GLD'))); @@ -32,163 +32,171 @@ const GazetteIssuePage = Loadable(lazy(() => import('pages/GazetteIssue/index')) const DrImport = Loadable(lazy(() => import('pages/Setting/DrImport'))); const AuditLogPage = Loadable(lazy(() => import('pages/AuditLog/index'))); const ReconReportPage = Loadable(lazy(() => import('pages/Recon'))); +const ChangePasswordPage = Loadable(lazy(() => import('pages/User/ChangePasswordPage'))); + // ==============================|| MAIN ROUTING ||============================== // const GLDUserRoutes = { path: '/', element: , children: [ + ( + isPasswordExpiry()? + { + path: '/', + element: + }: + { + path: '/', + element: + } + ), { - path: '/', - element: - }, - { - path: '/', - children: [ - { - path: '/dashboard', - element: - }, - { - path: '/application/:id', - element: - }, - { - path: '/application/search', - element: - }, - - isGranted(["MAINTAIN_PAYMENT"])? - { - path: '/application/markAsPaid/search', - element: - }:{}, - - isGrantedAny(["VIEW_PROOF","MAINTAIN_PROOF"])?{ - path: '/proof/search', - element: - }:{}, - - isGranted("MAINTAIN_PROOF")? - { - path: '/proof/create/:id', - element: - }:{}, - - isGrantedAny(["VIEW_PROOF","MAINTAIN_PROOF"])?{ - path: '/proof/reply/:id', - element: - }:{}, - - isGranted(["MAINTAIN_PAYMENT"])? - { - path: '/paymentPage/search', - element: - }:{}, - - isGranted(["MAINTAIN_PAYMENT"])? - { - path: '/paymentPage/details/:id', - element: - }:{}, - - isGranted(["MAINTAIN_DEMANDNOTE"])? - { - path: '/paymentPage/createDemandNote', - element: - }:{}, - - isGranted(["MAINTAIN_DEMANDNOTE"])? - { - path: '/paymentPage/exportGDN', - element: - }:{}, - - isGrantedAny(["VIEW_DEMANDNOTE","MAINTAIN_DEMANDNOTE"])? - { - path: '/paymentPage/demandNote', - element: - }:{}, - - isGrantedAny(["VIEW_DEMANDNOTE","MAINTAIN_DEMANDNOTE"])? - { - path: '/paymentPage/demandNote/details/:id', - element: - }:{}, - - isGranted("MAINTAIN_RECON") ? - { - path: '/paymentPage/reconReport', - element: - }:{}, - - isGranted("MAINTAIN_RECON") ? - { - path: '/gfmis/search', - element: - }:{}, - - - { - path: '/user/profile', - element: - }, - - isGranted("MAINTAIN_SETTING") ? - { - path: '/setting/sys', - element: - }:{}, - - isGranted("MAINTAIN_ANNOUNCEMENT") ? - { - path: '/setting/announcement', - element: - }:{}, - - isGranted("MAINTAIN_ANNOUNCEMENT")? - { - path: '/setting/announcement/details/:id', - element: - }:{}, - - isGranted("MAINTAIN_EMAIL")? - { - path: '/setting/emailTemplate', - element: - }:{}, - - isGranted("MAINTAIN_EMAIL")? - { - path: '/setting/emailTemplate/:id', - element: - }:{}, - - isGranted("MAINTAIN_GAZETTE_ISSUE")? - { - path: '/setting/holiday', - element: - }:{}, - - isGranted("MAINTAIN_GAZETTE_ISSUE")? - { - path: '/setting/gazetteissuepage', - element: - }:{}, - - isGranted("MAINTAIN_DR")? - { - path: '/setting/drImport', - element: - }:{}, - - - { - path: '/setting/auditLog', - element: - }, - ] - }, + path: '/', + children: [ + { + path: '/dashboard', + element: + }, + { + path: '/application/:id', + element: + }, + { + path: '/application/search', + element: + }, + + isGranted(["MAINTAIN_PAYMENT"])? + { + path: '/application/markAsPaid/search', + element: + }:{}, + + isGrantedAny(["VIEW_PROOF","MAINTAIN_PROOF"])?{ + path: '/proof/search', + element: + }:{}, + + isGranted("MAINTAIN_PROOF")? + { + path: '/proof/create/:id', + element: + }:{}, + + isGrantedAny(["VIEW_PROOF","MAINTAIN_PROOF"])?{ + path: '/proof/reply/:id', + element: + }:{}, + + isGranted(["MAINTAIN_PAYMENT"])? + { + path: '/paymentPage/search', + element: + }:{}, + + isGranted(["MAINTAIN_PAYMENT"])? + { + path: '/paymentPage/details/:id', + element: + }:{}, + + isGranted(["MAINTAIN_DEMANDNOTE"])? + { + path: '/paymentPage/createDemandNote', + element: + }:{}, + + isGranted(["MAINTAIN_DEMANDNOTE"])? + { + path: '/paymentPage/exportGDN', + element: + }:{}, + + isGrantedAny(["VIEW_DEMANDNOTE","MAINTAIN_DEMANDNOTE"])? + { + path: '/paymentPage/demandNote', + element: + }:{}, + + isGrantedAny(["VIEW_DEMANDNOTE","MAINTAIN_DEMANDNOTE"])? + { + path: '/paymentPage/demandNote/details/:id', + element: + }:{}, + + isGranted("MAINTAIN_RECON") ? + { + path: '/paymentPage/reconReport', + element: + }:{}, + + isGranted("MAINTAIN_RECON") ? + { + path: '/gfmis/search', + element: + }:{}, + + + { + path: '/user/profile', + element: + }, + + isGranted("MAINTAIN_SETTING") ? + { + path: '/setting/sys', + element: + }:{}, + + isGranted("MAINTAIN_ANNOUNCEMENT") ? + { + path: '/setting/announcement', + element: + }:{}, + + isGranted("MAINTAIN_ANNOUNCEMENT")? + { + path: '/setting/announcement/details/:id', + element: + }:{}, + + isGranted("MAINTAIN_EMAIL")? + { + path: '/setting/emailTemplate', + element: + }:{}, + + isGranted("MAINTAIN_EMAIL")? + { + path: '/setting/emailTemplate/:id', + element: + }:{}, + + isGranted("MAINTAIN_GAZETTE_ISSUE")? + { + path: '/setting/holiday', + element: + }:{}, + + isGranted("MAINTAIN_GAZETTE_ISSUE")? + { + path: '/setting/gazetteissuepage', + element: + }:{}, + + isGranted("MAINTAIN_DR")? + { + path: '/setting/drImport', + element: + }:{}, + { + path: '/setting/auditLog', + element: + }, + ] + }, + ] }; diff --git a/src/routes/PublicUserRoutes.js b/src/routes/PublicUserRoutes.js index 6ea64e0..67c7bec 100644 --- a/src/routes/PublicUserRoutes.js +++ b/src/routes/PublicUserRoutes.js @@ -4,6 +4,7 @@ import { lazy } from 'react'; import Loadable from 'components/Loadable'; // import MainLayout from 'layout/MainLayout'; const MainLayout = Loadable(lazy(() => import('layout/MainLayout'))); +import { isPasswordExpiry } from "utils/Utils"; // render - dashboard const DashboardDefault = Loadable(lazy(() => import('pages/Dashboard/Public'))); @@ -30,6 +31,7 @@ const Msg_Details = Loadable(lazy(() => import('pages/Message/Details'))); const Msg_Search = Loadable(lazy(() => import('pages/Message/Search'))); const AnnouncementSearch = Loadable(lazy(() => import('pages/Announcement/Search_Public'))); const IAmSmart_SuccessCallback = Loadable(lazy(() => import('pages/iAmSmart/SuccessCallback'))); +const ChangePasswordPage = Loadable(lazy(() => import('pages/User/ChangePasswordPage'))); // ==============================|| MAIN ROUTING ||============================== // @@ -38,10 +40,17 @@ const PublicDashboard = { path: '/', element: , children: [ - { - path: '/', - element: - }, + ( + isPasswordExpiry()? + { + path: '/', + element: + }: + { + path: '/', + element: + } + ), { path: '/', children: [ @@ -141,8 +150,13 @@ const PublicDashboard = { path: '/announcement/search', element: }, + { + path: '/user/changePassword', + element: + } ] - }, + } + ] }; diff --git a/src/routes/index.js b/src/routes/index.js index 27969c8..178822c 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -31,16 +31,18 @@ export default function ThemeRoutes() { return useRoutes([{ path: '', children: [ - (isUserLoggedIn() ? - { - path: '', - element: - } + ( + isUserLoggedIn() ? + { + path: '', + element: + } : - { - path: '', - element: - }) + { + path: '', + element: + } + ) ] }, // isUserLoggedIn() ? MainRoutes : LoginRoutes, diff --git a/src/translations/zh-CN.json b/src/translations/zh-CN.json index d99324a..b490d42 100644 --- a/src/translations/zh-CN.json +++ b/src/translations/zh-CN.json @@ -334,7 +334,7 @@ "pwRemark2": "字母和数字的混合", "pwRemark3": "英文字母大写与小写的混合", "pwRemark4": "至少包含一个特殊符号,例如,@ # ?", - "pwRemark5": "請注意,嚴禁使用字典單字、使用者名稱或明顯短語作為密碼內容。", + "pwRemark5": "请注意,严禁使用字典单词、用户名或明显的短语作为密码内容。", "pwWeak": "弱", "pwNormal": "普通", "pwGood": "良好", diff --git a/src/translations/zh-HK.json b/src/translations/zh-HK.json index a9556b1..608090d 100644 --- a/src/translations/zh-HK.json +++ b/src/translations/zh-HK.json @@ -337,7 +337,7 @@ "pwRemark2": "字母和數字的混合", "pwRemark3": "英文字母大寫與小寫的混合", "pwRemark4": "至少包含一個特殊符號,例如,@ # ?", - "pwRemark5": "请注意,严禁使用字典单词、用户名或明显的短语作为密码内容。", + "pwRemark5": "請注意,嚴禁使用字典單字、使用者名稱或明顯短語作為密碼內容。", "pwWeak": "弱", "pwNormal": "普通", "pwGood": "良好", diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 6950b1e..f5225c7 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -1,3 +1,5 @@ +import * as DateUtils from "utils/DateUtils" + export const defaultHomePage = '/dashboard' // ** Checks if an object is empty (returns boolean) @@ -147,3 +149,25 @@ export const getUserId = () =>{ return JSON.parse(localStorage.getItem('userData')).id } } + +export const isPasswordExpiry = () =>{ + var date; + if (localStorage.getItem('userData') != null){ + date = JSON.parse(localStorage.getItem('userData')).passwordExpiryDate + } + if (date != null){ + var currentDate = new Date(); + var expirationDate = DateUtils.convertToDate(date); + + if (expirationDate < currentDate) { + console.log(true) + return true; // The date has expired + } else { + console.log(false) + return false; // The date is still valid + } + }else{ + return false; + } + +} \ No newline at end of file