From 04ae8a087d31457d7d641de4d8476e182bf8ec1b Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Tue, 30 Jan 2024 18:26:02 +0800 Subject: [PATCH] update with forgot passworf and loayout update --- src/pages/DemandNote/Search/index.js | 6 +- src/pages/DemandNote/Search_Public/index.js | 6 +- src/pages/EmailTemplate/Detail_GLD/index.js | 6 +- src/pages/EmailTemplate/Search_GLD/index.js | 6 +- src/pages/Message/Details/index.js | 6 +- src/pages/Organization/DetailPage/index.js | 6 +- src/pages/Organization/SearchPage/index.js | 6 +- src/pages/Payment/Card/index.js | 6 +- src/pages/Payment/Details_GLD/index.js | 6 +- src/pages/Payment/Details_Public/index.js | 6 +- src/pages/Payment/FPS/AckPage.js | 6 +- src/pages/Payment/FPS/FPS.js | 6 +- src/pages/Payment/FPS/fpscallback.js | 6 +- src/pages/Payment/PaymentCallback.js | 6 +- src/pages/Proof/Create_FromApp/index.js | 7 +- src/pages/Proof/Payment/Pay.js | 6 +- src/pages/Proof/Payment/Pay_Creditor.js | 6 +- src/pages/Proof/Reply_GLD/index.js | 6 +- src/pages/Proof/Reply_Public/index.js | 6 +- src/pages/Proof/Search_GLD/index.js | 6 +- src/pages/PublicNotice/ApplyForm/index.js | 7 +- src/pages/PublicNotice/ListPanel/index.js | 6 +- src/pages/PublicNotice/Search_GLD/index.js | 6 +- src/pages/User/DetailPage/index.js | 6 +- .../User/DetailsPage_Individual/index.js | 6 +- .../User/DetailsPage_Organization/index.js | 6 +- src/pages/User/GLDUserProfile/index.js | 6 +- src/pages/User/SearchPage/index.js | 6 +- src/pages/User/SearchPage_Individual/index.js | 6 +- .../User/SearchPage_Organization/index.js | 6 +- .../ForgotPassword/AfterForgotPasswordPage.js | 376 +++--------- .../ForgotPassword/AuthCallback/index.js | 535 ++++++++++++++++-- .../ForgotPassword/ForgotPasswordApplyForm.js | 5 +- .../authentication/ForgotPassword/index.js | 13 +- src/pages/authentication/Verify.js | 34 +- src/pages/iAmSmart/AuthCallback/index.js | 10 +- .../iAmSmart/DirectLoginCallback/index.js | 10 +- src/pages/iAmSmart/FailCallback/index.js | 6 +- src/pages/iAmSmart/RegistryCallback/index.js | 10 +- src/pages/iAmSmart/SuccessCallback/index.js | 6 +- src/pages/pnspsUserGroupDetailPage/index.js | 6 +- src/pages/pnspsUserGroupSearchPage/index.js | 6 +- src/routes/AfterLoginRoutes.js | 16 + src/routes/LoginRoutes.js | 11 +- src/translations/en.json | 8 + src/translations/zh-CN.json | 8 + src/translations/zh-HK.json | 9 + src/utils/ApiPathConst.js | 2 + 48 files changed, 831 insertions(+), 422 deletions(-) diff --git a/src/pages/DemandNote/Search/index.js b/src/pages/DemandNote/Search/index.js index bc6e38c..7f2120e 100644 --- a/src/pages/DemandNote/Search/index.js +++ b/src/pages/DemandNote/Search/index.js @@ -92,7 +92,11 @@ const UserSearchPage_Individual = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/DemandNote/Search_Public/index.js b/src/pages/DemandNote/Search_Public/index.js index 2602a46..18c185c 100644 --- a/src/pages/DemandNote/Search_Public/index.js +++ b/src/pages/DemandNote/Search_Public/index.js @@ -92,7 +92,11 @@ const UserSearchPage_Individual = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/EmailTemplate/Detail_GLD/index.js b/src/pages/EmailTemplate/Detail_GLD/index.js index 3471fa6..8e03f5b 100644 --- a/src/pages/EmailTemplate/Detail_GLD/index.js +++ b/src/pages/EmailTemplate/Detail_GLD/index.js @@ -117,7 +117,11 @@ const Index = () => { return ( !onReady ? - + + + + + : ( diff --git a/src/pages/EmailTemplate/Search_GLD/index.js b/src/pages/EmailTemplate/Search_GLD/index.js index f45730b..4358b7b 100644 --- a/src/pages/EmailTemplate/Search_GLD/index.js +++ b/src/pages/EmailTemplate/Search_GLD/index.js @@ -55,7 +55,11 @@ const Index = () => { return ( !onReady ? - + + + + + : ( diff --git a/src/pages/Message/Details/index.js b/src/pages/Message/Details/index.js index 25254fc..29a65a2 100644 --- a/src/pages/Message/Details/index.js +++ b/src/pages/Message/Details/index.js @@ -61,7 +61,11 @@ const Index = () => { return ( !onReady ? - + + + + + : ( diff --git a/src/pages/Organization/DetailPage/index.js b/src/pages/Organization/DetailPage/index.js index 7e0d8c5..5d7ee4f 100644 --- a/src/pages/Organization/DetailPage/index.js +++ b/src/pages/Organization/DetailPage/index.js @@ -124,7 +124,11 @@ const OrganizationDetailPage = () => { return ( isLoading ? - + + + + + : diff --git a/src/pages/Organization/SearchPage/index.js b/src/pages/Organization/SearchPage/index.js index a805885..3218eef 100644 --- a/src/pages/Organization/SearchPage/index.js +++ b/src/pages/Organization/SearchPage/index.js @@ -65,7 +65,11 @@ const OrganizationSearchPage = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/Payment/Card/index.js b/src/pages/Payment/Card/index.js index 977678d..be8249d 100644 --- a/src/pages/Payment/Card/index.js +++ b/src/pages/Payment/Card/index.js @@ -125,7 +125,11 @@ const Index = () => { return ( !onReady ? - + + + + + : ( diff --git a/src/pages/Payment/Details_GLD/index.js b/src/pages/Payment/Details_GLD/index.js index cde724f..f4f36c3 100644 --- a/src/pages/Payment/Details_GLD/index.js +++ b/src/pages/Payment/Details_GLD/index.js @@ -79,7 +79,11 @@ const Index = () => { return ( !onReady ? - + + + + + : (
diff --git a/src/pages/Payment/Details_Public/index.js b/src/pages/Payment/Details_Public/index.js index fa0960c..cb69dc7 100644 --- a/src/pages/Payment/Details_Public/index.js +++ b/src/pages/Payment/Details_Public/index.js @@ -84,7 +84,11 @@ const Index = () => { return ( !onReady ? - + + + + + : (
diff --git a/src/pages/Payment/FPS/AckPage.js b/src/pages/Payment/FPS/AckPage.js index af68172..6281fb8 100644 --- a/src/pages/Payment/FPS/AckPage.js +++ b/src/pages/Payment/FPS/AckPage.js @@ -149,7 +149,11 @@ const AckPage = () => { return ( !onReady ? - + + + + + : transactionData.paymentdetail?.result?.paymentstatuscode === "APPR" ? ( diff --git a/src/pages/Payment/FPS/FPS.js b/src/pages/Payment/FPS/FPS.js index 7250439..7de61e8 100644 --- a/src/pages/Payment/FPS/FPS.js +++ b/src/pages/Payment/FPS/FPS.js @@ -256,7 +256,11 @@ const Index = () => { return ( !onReady ? - + + + + + : ( diff --git a/src/pages/Payment/FPS/fpscallback.js b/src/pages/Payment/FPS/fpscallback.js index 3a40e95..61bce13 100644 --- a/src/pages/Payment/FPS/fpscallback.js +++ b/src/pages/Payment/FPS/fpscallback.js @@ -139,7 +139,11 @@ const Fpscallback = () => { } return ( !onReady ? - + + + + + : transactionData.paymentdetail?.result?.paymentstatuscode === "APPR" ? ( diff --git a/src/pages/Payment/PaymentCallback.js b/src/pages/Payment/PaymentCallback.js index 1f33325..283297a 100644 --- a/src/pages/Payment/PaymentCallback.js +++ b/src/pages/Payment/PaymentCallback.js @@ -151,7 +151,11 @@ const Index = () => { return ( !onReady ? - + + + + + : transactionData.paymentdetail?.result?.paymentstatuscode === "APPR" ? ( diff --git a/src/pages/Proof/Create_FromApp/index.js b/src/pages/Proof/Create_FromApp/index.js index 06659f0..1299d75 100644 --- a/src/pages/Proof/Create_FromApp/index.js +++ b/src/pages/Proof/Create_FromApp/index.js @@ -68,9 +68,12 @@ const Index = () => { return ( !onReady ? - + + + + + : -
diff --git a/src/pages/Proof/Payment/Pay.js b/src/pages/Proof/Payment/Pay.js index 9fad007..46ef276 100644 --- a/src/pages/Proof/Payment/Pay.js +++ b/src/pages/Proof/Payment/Pay.js @@ -80,7 +80,11 @@ const Index = () => { return ( !onReady ? - + + + + + : ( diff --git a/src/pages/Proof/Payment/Pay_Creditor.js b/src/pages/Proof/Payment/Pay_Creditor.js index bea153b..94998cf 100644 --- a/src/pages/Proof/Payment/Pay_Creditor.js +++ b/src/pages/Proof/Payment/Pay_Creditor.js @@ -60,7 +60,11 @@ const Index = () => { return ( !onReady ? - + + + + + : ( diff --git a/src/pages/Proof/Reply_GLD/index.js b/src/pages/Proof/Reply_GLD/index.js index 741f413..a22c395 100644 --- a/src/pages/Proof/Reply_GLD/index.js +++ b/src/pages/Proof/Reply_GLD/index.js @@ -112,7 +112,11 @@ const Index = () => { return ( !onReady ? - + + + + + : ( diff --git a/src/pages/Proof/Reply_Public/index.js b/src/pages/Proof/Reply_Public/index.js index bed3ac6..0e9c584 100644 --- a/src/pages/Proof/Reply_Public/index.js +++ b/src/pages/Proof/Reply_Public/index.js @@ -81,7 +81,11 @@ const Index = () => { return ( !onReady ? - + + + + + : ( diff --git a/src/pages/Proof/Search_GLD/index.js b/src/pages/Proof/Search_GLD/index.js index 4cd5764..ede9572 100644 --- a/src/pages/Proof/Search_GLD/index.js +++ b/src/pages/Proof/Search_GLD/index.js @@ -90,7 +90,11 @@ const UserSearchPage_Individual = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/PublicNotice/ApplyForm/index.js b/src/pages/PublicNotice/ApplyForm/index.js index af41ca4..a2195ce 100644 --- a/src/pages/PublicNotice/ApplyForm/index.js +++ b/src/pages/PublicNotice/ApplyForm/index.js @@ -6,6 +6,7 @@ import * as DateUtils from "utils/DateUtils"; import * as FormatUtils from "utils/FormatUtils"; import { + Grid, Radio, FormControlLabel } from '@mui/material'; @@ -64,7 +65,11 @@ const ApplyForm = () => { return ( isLoading ? - + + + + + : { return ( isLoading ? - + + + + + : diff --git a/src/pages/PublicNotice/Search_GLD/index.js b/src/pages/PublicNotice/Search_GLD/index.js index ce0bd12..68dbe80 100644 --- a/src/pages/PublicNotice/Search_GLD/index.js +++ b/src/pages/PublicNotice/Search_GLD/index.js @@ -90,7 +90,11 @@ const UserSearchPage_Individual = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/User/DetailPage/index.js b/src/pages/User/DetailPage/index.js index 9ae8562..567f74a 100644 --- a/src/pages/User/DetailPage/index.js +++ b/src/pages/User/DetailPage/index.js @@ -202,7 +202,11 @@ const UserMaintainPage = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/User/DetailsPage_Individual/index.js b/src/pages/User/DetailsPage_Individual/index.js index 6445bcf..3467e48 100644 --- a/src/pages/User/DetailsPage_Individual/index.js +++ b/src/pages/User/DetailsPage_Individual/index.js @@ -118,7 +118,11 @@ const UserMaintainPage_Individual = () => { return ( isLoading ? - + + + + + : diff --git a/src/pages/User/DetailsPage_Organization/index.js b/src/pages/User/DetailsPage_Organization/index.js index 023a69c..22b45c7 100644 --- a/src/pages/User/DetailsPage_Organization/index.js +++ b/src/pages/User/DetailsPage_Organization/index.js @@ -179,7 +179,11 @@ const UserMaintainPage_Organization = () => { return ( isLoading ? - + + + + + : diff --git a/src/pages/User/GLDUserProfile/index.js b/src/pages/User/GLDUserProfile/index.js index f77df99..75353ef 100644 --- a/src/pages/User/GLDUserProfile/index.js +++ b/src/pages/User/GLDUserProfile/index.js @@ -75,7 +75,11 @@ const UserMaintainPage = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/User/SearchPage/index.js b/src/pages/User/SearchPage/index.js index fba0ad2..6d3fb7b 100644 --- a/src/pages/User/SearchPage/index.js +++ b/src/pages/User/SearchPage/index.js @@ -70,7 +70,11 @@ const UserSettingPage = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/User/SearchPage_Individual/index.js b/src/pages/User/SearchPage_Individual/index.js index 131505b..ed9687a 100644 --- a/src/pages/User/SearchPage_Individual/index.js +++ b/src/pages/User/SearchPage_Individual/index.js @@ -65,7 +65,11 @@ const UserSearchPage_Individual = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/User/SearchPage_Organization/index.js b/src/pages/User/SearchPage_Organization/index.js index e789caa..959a250 100644 --- a/src/pages/User/SearchPage_Organization/index.js +++ b/src/pages/User/SearchPage_Organization/index.js @@ -66,7 +66,11 @@ const UserSearchPage_Organization = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/authentication/ForgotPassword/AfterForgotPasswordPage.js b/src/pages/authentication/ForgotPassword/AfterForgotPasswordPage.js index 84ca616..6311b22 100644 --- a/src/pages/authentication/ForgotPassword/AfterForgotPasswordPage.js +++ b/src/pages/authentication/ForgotPassword/AfterForgotPasswordPage.js @@ -3,33 +3,18 @@ import { Grid, Typography, Button, - // RadioGroup, - Dialog, DialogTitle, DialogContent, DialogActions, Stack, InputLabel, - // OutlinedInput, - FormHelperText, - TextField, - IconButton, InputAdornment, - // Box, - // FormControl } from '@mui/material'; -import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons'; -// import { strengthColorChi, strengthIndicator } from 'utils/password-strength'; -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 * as FieldUtils from "utils/FieldUtils"; + import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' import ForwardIcon from '@mui/icons-material/Forward'; import MainCard from 'components/MainCard'; import { useNavigate } from "react-router-dom"; -// import { notifyActionSuccess } from 'utils/CommonFunction'; import {PNSPS_LONG_BUTTON_THEME} from "themes/buttonConst"; import {ThemeProvider} from "@emotion/react"; import {FormattedMessage, useIntl} from "react-intl"; @@ -37,13 +22,7 @@ import {FormattedMessage, useIntl} from "react-intl"; // ==============================|| DASHBOARD - DEFAULT ||============================== // const AfterForgotPasswordPage = () => { - const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); - const [showPassword, setShowPassword] = React.useState(false); - const [showConfirmPassword, setshowConfirmPassword] = React.useState(false); - // const [level, setLevel] = React.useState(); const intl = useIntl(); - - // const [issueId, setIssueId] = React.useState(loadedData.issueId); const navigate = useNavigate(); const BackgroundHead = { @@ -56,49 +35,11 @@ const AfterForgotPasswordPage = () => { 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 handleContinue = () => { + // setOpen(false); + navigate('/login'); }; - 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) - } - }); - return ( @@ -122,11 +63,11 @@ const AfterForgotPasswordPage = () => { {/* 申請公共啟事 */} - + *': { flexGrow: 1, flexBasis: '50%' @@ -136,253 +77,80 @@ const AfterForgotPasswordPage = () => { border={false} boxShadow > -
- - - - - - - - - - - - - - - - - - - - - - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - InputLabelProps={{ - shrink: true - }} - /> - - {formik.touched.emailVerifyHash && formik.errors.emailVerifyHash && ( - - {formik.errors.emailVerifyHash} - - )} + + + + + + + + + - - - - - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - InputLabelProps={{ - shrink: true - }} - /> - - {formik.touched.username && formik.errors.username && ( - - {formik.errors.username} - - )} + + + + + + + {/* + + + + + + */} - - - - { - formik.handleChange(e); - changePassword(e.target.value); - }} - id="password" - type={showPassword ? 'text' : 'password'} - name="password" - placeholder={intl.formatMessage({id: 'userPassword'})} - label={intl.formatMessage({id: 'userPassword'}) + ":"} - // 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" - placeholder={intl.formatMessage({id: 'confirmPassword'})} - label={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} - - )} + + + + + + + + + + + + + + {/* + + + + + + */} - - - - - - + + + + + + +
-
- setIsWarningPopUp(false)} - PaperProps={{ - sx: { - minWidth: '40vw', - maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' }, - maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' } - } - }} - > - - - - - {/* {warningText} */} - - - - - -
); }; diff --git a/src/pages/authentication/ForgotPassword/AuthCallback/index.js b/src/pages/authentication/ForgotPassword/AuthCallback/index.js index cf89e89..dec6731 100644 --- a/src/pages/authentication/ForgotPassword/AuthCallback/index.js +++ b/src/pages/authentication/ForgotPassword/AuthCallback/index.js @@ -1,85 +1,504 @@ - +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'; // ==============================|| 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 params = useParams() + const intl = useIntl(); + React.useEffect(() => { - goLogin(); + setEnterUseEffect(true) }, []); - function goLogin(){ - dispatch(handleLogoutFunction()); + React.useEffect(() => { + // console.log("if (enterUseEffect) handleVerify()"); + if (enterUseEffect){ + handleVerify() + } + }, [enterUseEffect]) - let params = new URLSearchParams(window.location.search) - if(params.get("code")){ - HttpUtils.post({ - url: UrlUtils.GET_SMART_LOGIN, - params:{ - code: params.get("code") - }, - onSuccess: (responseData) => { - console.log("responseData"); - console.log(responseData); - const userData = { - id: responseData.id, - fullenName: responseData.name, - fullchName: responseData.chName, - email: responseData.email, - type: responseData.type, - role: responseData.role, - abilities: responseData.abilities, - creditor: responseData.creditor, - locale: responseData.preferLocale, - //avatar: require('src/assets/images/users/avatar-3.png').default, + 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(true) + } + setLoding(false) + } + ).catch(error => { + console.log(error) + setVerifyState(true) + setLoding(false) + }); + + + } + + const goLogin = async (values) =>{ + dispatch(handleLogoutFunction()); + console.log(username) + await axios.patch(UrlUtils.PATCH_FORGOT_PASSWORD_NEW_PASSWORD, { + params: { + username: username, + newPassword: values.password + } + }).then( + (response)=>{ + if (response.status === 204) { + useJwt + .login({ username: username, password: values.password }) + .then((response) => { + // console.log(response) + const userData = { + id: response.data.id, + fullenName: response.data.name, + fullchName: response.data.chName, + email: response.data.email, + type: response.data.type, + role: response.data.role, + abilities: response.data.abilities, + creditor: response.data.creditor, + locale: response.data.preferLocale, + //avatar: require('src/assets/images/users/avatar-3.png').default, + } + const data = { ...userData, accessToken: response.data.accessToken, refreshToken: response.data.refreshToken } + // setSuccess(true) + // console.log(response.data); + if(response.data.type === "GLD"){ + setLocale("en"); + localStorage.setItem('locale','en'); + }else{ + if (response.data.preferLocale ==="zh_HK"){ + setLocale("zh-HK"); + localStorage.setItem('locale','zh-HK'); } - const data = { ...userData, accessToken: responseData.accessToken, refreshToken: responseData.refreshToken } - if(responseData.type === "GLD"){ - setLocale("en"); - localStorage.setItem('locale','en'); - }else{ - if (responseData.preferLocale ==="zh_HK"){ - setLocale("zh-HK"); - localStorage.setItem('locale','zh-HK'); - } - if (responseData.preferLocale ==="zh-CN"){ - setLocale("zh-CN"); - localStorage.setItem('locale','zh-CN'); - } + if (response.data.preferLocale ==="zh-CN"){ + setLocale("zh-CN"); + localStorage.setItem('locale','zh-CN'); } - dispatch(handleLogin(data)) - navigate('/dashboard'); - }, - onFail: (response)=>{ - console.log("Fail"); - console.log(response); - window.location.assign("/iamsmart/loginFail"); - }, - onError:(error)=>{ - console.log(error); - window.location.assign("/iamsmart/loginFail"); + } + dispatch(handleLogin(data)) + navigate('/dashboard'); + location.reload() + // setSumitting(false) + }) + .catch((error) => { + // setSuccess(false) + console.error(error) + console.error(error.response.data.error) + setErrorMassage(error.response.data.error) + setOpen(true) + }); + } else { + setVerifyState(true) } - }); - }else{ - window.location.assign("/iamsmart/loginFail"); - } + setLoding(false) + } + ).catch(error => { + console.log(error) + setVerifyState(true) + setLoding(false) + }); + HttpUtils.patch({ + url: UrlUtils.PATCH_FORGOT_PASSWORD_NEW_PASSWORD, + params:{ + username: username, + newPassword: values.password + }, + onSuccess: () => { + + }, + 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 + + + {/* */} + + + + 驗證失敗,請聯絡相關的系統管理員協助。 + + + + + + } + + + + +
+
+
+
); }; diff --git a/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js b/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js index daf877f..2e6481b 100644 --- a/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js +++ b/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js @@ -60,6 +60,7 @@ const ForgotPasswordApplyForm = () => { }), onSubmit: values => { console.log(values) + navigate('/forgot/password/sent'); // HttpUtils.postWithFiles({ // url: UrlUtils.POST_PUBLIC_NOTICE_APPLY, @@ -115,7 +116,7 @@ const ForgotPasswordApplyForm = () => { *': { flexGrow: 1, flexBasis: '50%' @@ -135,7 +136,7 @@ const ForgotPasswordApplyForm = () => {
- + diff --git a/src/pages/authentication/ForgotPassword/index.js b/src/pages/authentication/ForgotPassword/index.js index 50628b6..01aa418 100644 --- a/src/pages/authentication/ForgotPassword/index.js +++ b/src/pages/authentication/ForgotPassword/index.js @@ -5,10 +5,9 @@ import * as React from "react"; // import * as DateUtils from "utils/DateUtils"; // import * as FormatUtils from "utils/FormatUtils"; -// import { -// Radio, -// FormControlLabel -// } from '@mui/material'; +import { + Grid +} from '@mui/material'; import Loadable from 'components/Loadable'; import { lazy } from 'react'; @@ -33,7 +32,11 @@ const ApplyForm = () => { return ( isLoading ? - + + + + + : { - console.log("setEnterUseEffect(true)"); + // console.log("setEnterUseEffect(true)"); setEnterUseEffect(true) }, []) useEffect(() => { - console.log("if (enterUseEffect) handleVerify()"); + // console.log("if (enterUseEffect) handleVerify()"); if (enterUseEffect) handleVerify() }, [enterUseEffect]) @@ -56,26 +56,38 @@ export default function Verify() { {isLoading || verifyState == null ? - : + + + + + : {verifyState ? // SUCCESS page - 帳戶已成功驗證。 - + + + + : // ERROR page {/* */} - 驗證失敗,請聯絡相關的系統管理員協助。 - + + + + } diff --git a/src/pages/iAmSmart/AuthCallback/index.js b/src/pages/iAmSmart/AuthCallback/index.js index cf89e89..1d0e345 100644 --- a/src/pages/iAmSmart/AuthCallback/index.js +++ b/src/pages/iAmSmart/AuthCallback/index.js @@ -8,7 +8,9 @@ import { handleLogoutFunction, handleLogin } from 'auth/index'; import Loadable from 'components/Loadable'; const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); - +import { + Grid, +} from '@mui/material'; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -79,7 +81,11 @@ const Index = () => { } return ( - + + + + + ); }; diff --git a/src/pages/iAmSmart/DirectLoginCallback/index.js b/src/pages/iAmSmart/DirectLoginCallback/index.js index e122bfe..e7e3227 100644 --- a/src/pages/iAmSmart/DirectLoginCallback/index.js +++ b/src/pages/iAmSmart/DirectLoginCallback/index.js @@ -8,7 +8,9 @@ import { handleLogoutFunction, handleLogin } from 'auth/index'; import Loadable from 'components/Loadable'; const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); - +import { + Grid, +} from '@mui/material'; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -64,7 +66,11 @@ const Index = () => { } return ( - + + + + + ); }; diff --git a/src/pages/iAmSmart/FailCallback/index.js b/src/pages/iAmSmart/FailCallback/index.js index 06527cd..aec67f7 100644 --- a/src/pages/iAmSmart/FailCallback/index.js +++ b/src/pages/iAmSmart/FailCallback/index.js @@ -24,7 +24,11 @@ const Index = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/iAmSmart/RegistryCallback/index.js b/src/pages/iAmSmart/RegistryCallback/index.js index ab69b32..a489d7b 100644 --- a/src/pages/iAmSmart/RegistryCallback/index.js +++ b/src/pages/iAmSmart/RegistryCallback/index.js @@ -5,7 +5,9 @@ import * as UrlUtils from "utils/ApiPathConst"; import { useNavigate } from "react-router-dom"; import Loadable from 'components/Loadable'; const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); - +import { + Grid, +} from '@mui/material'; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -44,7 +46,11 @@ const Index = () => { } return ( - + + + + + ); }; diff --git a/src/pages/iAmSmart/SuccessCallback/index.js b/src/pages/iAmSmart/SuccessCallback/index.js index cf6f2d0..1273659 100644 --- a/src/pages/iAmSmart/SuccessCallback/index.js +++ b/src/pages/iAmSmart/SuccessCallback/index.js @@ -32,7 +32,11 @@ const Index = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/pnspsUserGroupDetailPage/index.js b/src/pages/pnspsUserGroupDetailPage/index.js index ab49e9e..cfb6bb3 100644 --- a/src/pages/pnspsUserGroupDetailPage/index.js +++ b/src/pages/pnspsUserGroupDetailPage/index.js @@ -167,7 +167,11 @@ const UserMaintainPage = () => { return ( !onReady ? - + + + + + : diff --git a/src/pages/pnspsUserGroupSearchPage/index.js b/src/pages/pnspsUserGroupSearchPage/index.js index c0bb997..b045aca 100644 --- a/src/pages/pnspsUserGroupSearchPage/index.js +++ b/src/pages/pnspsUserGroupSearchPage/index.js @@ -73,7 +73,11 @@ const UserGroupSearchPanel = () => { return ( !onReady ? - + + + + + : diff --git a/src/routes/AfterLoginRoutes.js b/src/routes/AfterLoginRoutes.js index a8d1c62..4e745ef 100644 --- a/src/routes/AfterLoginRoutes.js +++ b/src/routes/AfterLoginRoutes.js @@ -48,6 +48,22 @@ const AfterLoginRoutes = { path: 'verify/:verifyCode/:email', element: }, + { + path: 'forgot/password', + element: + }, + { + path: 'forgot/password/sent', + element: + }, + { + path: 'forgot/password/verify', + element: + }, + { + path: 'forgot/password/loginFail', + element: + }, ] }; diff --git a/src/routes/LoginRoutes.js b/src/routes/LoginRoutes.js index 56e8166..f7fc1bb 100644 --- a/src/routes/LoginRoutes.js +++ b/src/routes/LoginRoutes.js @@ -14,6 +14,7 @@ const IAmSmartRegister = Loadable(lazy(() => import('pages/authentication/IAmSma const ErrorPage = Loadable(lazy(() => import('pages/extra-pages/ErrorPage'))); const ForgotPassword = Loadable(lazy(() => import('pages/authentication/ForgotPassword'))); const AfterForgotPasswordPage = Loadable(lazy(() => import('pages/authentication/ForgotPassword/AfterForgotPasswordPage'))); +const ForgotPassword_Callback = Loadable(lazy(() => import('pages/authentication/ForgotPassword/AuthCallback'))); const IAmSmart_DirectLoginCallback = Loadable(lazy(() => import('pages/iAmSmart/DirectLoginCallback'))); //const IAmSmart_FallCallback = Loadable(lazy(() => import('pages/iAmSmart/FallCallback'))); @@ -107,9 +108,17 @@ const LoginRoutes = { element: }, { - path: 'forgot/password/verify', + path: 'forgot/password/sent', element: }, + { + path: 'forgot/password/verify/:verifyCode/:email', + element: + }, + { + path: 'forgot/password/loginFail', + element: + }, ] }; diff --git a/src/translations/en.json b/src/translations/en.json index 343441b..85fbd84 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -69,12 +69,18 @@ "register": "Register", "userLoginName": "Username", "userPassword": "Password", + "newPassword": "New Password", + "setNewPassword": "Please enter new password", "forgotUserPassword": "Forgot Password", "forgotPasswordTitle": "Find Your Account", "forgotPasswordSubTitle": "Please enter your username to receive the code to reset your password", "forgotPasswordSubTitle1": "Please enter your username to receive", "forgotPasswordSubTitle2": "the code to reset your password", "securityCode": "Security Code", + "sentSecurityCode1": "We sent your code to your setting email", + "sentSecurityCode2": "Please check your emails for a message with your code.", + "sentSecurityCode3": "Please check your emails for ", + "sentSecurityCode4": "a message with your code.", "requireSecurityCode": "Please enter security code", "learnMore": "Learn More", "createOrReActivate": "Create account", @@ -150,6 +156,8 @@ "acceptTerms": "I accept", "rejectTerms": "I do not accept", "verify": "Verify", + "verifySuccess": "Account verified successfully", + "verifyFail": "Verification failed, please contact the relevant system administrator for assistance.", "validVerify": "Please enter valid verification", "requiredValid": "Please enter valid ", "require": "Please enter ", diff --git a/src/translations/zh-CN.json b/src/translations/zh-CN.json index da341ce..79b4610 100644 --- a/src/translations/zh-CN.json +++ b/src/translations/zh-CN.json @@ -69,12 +69,18 @@ "register": "申请", "userLoginName": "用户登入名称", "userPassword": "密码", + "newPassword": "新密码", + "setNewPassword": "请输入新密码", "forgotUserPassword": "忘记密码", "forgotPasswordTitle": "寻找你的帐号", "forgotPasswordSubTitle": "请输入你的用户登入名称以重设密码", "forgotPasswordSubTitle1": "请输入你的用户登入名称收", "forgotPasswordSubTitle2": "以重设密码", "securityCode": "安全验证码", + "sentSecurityCode1": "我们已将验证码送至你的电邮:", + "sentSecurityCode2": "请查看你的电子邮件信箱中是否有包含验证码的信件。", + "sentSecurityCode3": "请查看你的电子邮件信箱中", + "sentSecurityCode4": "是否有包含验证码的信件。", "requireSecurityCode": "请输入安全验证码", "learnMore": "了解更多", "createOrReActivate": "建立帐户", @@ -112,6 +118,8 @@ "requireAtLeast2Number": "请输入最少2位数字", "requireDialingCode": "请输入国际区号", "requireVerify": "请输入验证", + "verifySuccess": "帐户已成功验证。", + "verifyFail": "验证失败,请联络相关的系统管理员协助。", "dialingCode": "国际区号", "userFaxNumber": "传真号码", "userIdDoc": "身份证明文件", diff --git a/src/translations/zh-HK.json b/src/translations/zh-HK.json index 1febe82..1c860e4 100644 --- a/src/translations/zh-HK.json +++ b/src/translations/zh-HK.json @@ -69,13 +69,20 @@ "register": "申請", "userLoginName": "用戶登入名稱", "userPassword": "密碼", + "newPassword": "新密碼", + "setNewPassword": "請輸入新密碼", "forgotUserPassword": "忘記密碼", "forgotPasswordTitle": "尋找你的帳號", "forgotPasswordSubTitle": "請輸入你的用戶登入名稱以重設密碼", "forgotPasswordSubTitle1": "請輸入你的用戶登入名稱", "forgotPasswordSubTitle2": "以重設密碼", "securityCode": "安全驗證碼", + "sentSecurityCode1": "我們已將驗證碼送至你的電郵:", + "sentSecurityCode2": "請查看你的電子郵件信箱中是否有包含驗證碼的信件。", + "sentSecurityCode3": "請查看你的電子郵件信箱中", + "sentSecurityCode4": "是否有包含驗證碼的信件。", "requireSecurityCode": "請輸入安全驗證碼", + "learnMore": "了解更多", "createOrReActivate": "建立帳戶", "usernameTaken": "此用戶登入名稱已被注冊,請使用其他用戶登入名稱", @@ -150,6 +157,8 @@ "acceptTerms": "我接受", "rejectTerms": "我不接受", "verify": "驗證", + "verifySuccess": "帳戶已成功驗證。", + "verifyFail": "驗證失敗,請聯絡相關的系統管理員協助。", "validVerify": "請輸入有效驗證", "requiredValid": "請輸入有效的", "require": "請輸入", diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index d536d9d..c458163 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -73,6 +73,8 @@ export const GET_USERNAME = apiPath+'/user/username'; export const GET_USER_EMAIL = apiPath+'/user/email'; export const GET_ID = apiPath+'/user/verifyID'; export const GET_VERIFY_USER_ACCOUNT = apiPath+'/user/verifyEmail'; +export const GET_FORGOT_PASSWORD_VERIFY_USER_ACCOUNT = apiPath+'/user/verifyForgotPasswordEmail'; +export const PATCH_FORGOT_PASSWORD_NEW_PASSWORD = apiPath+'/user/forgotPassword/newPassword'; //Public