From d6fca0218ae5ef224918be613fedfdaf14d1a1a9 Mon Sep 17 00:00:00 2001 From: "cyril.tsui" Date: Fri, 10 Nov 2023 15:42:38 +0800 Subject: [PATCH] update --- src/pages/authentication/Verify.js | 74 +++++++++++++++++++ .../auth-forms/PasswordAlertDialog.js | 67 +++++++++-------- src/routes/LoginRoutes.js | 5 ++ src/utils/ApiPathConst.js | 1 + 4 files changed, 116 insertions(+), 31 deletions(-) create mode 100644 src/pages/authentication/Verify.js diff --git a/src/pages/authentication/Verify.js b/src/pages/authentication/Verify.js new file mode 100644 index 0000000..dbcd8aa --- /dev/null +++ b/src/pages/authentication/Verify.js @@ -0,0 +1,74 @@ +// material-ui +import { Button, Grid } from '@mui/material'; +import { Link } from 'react-router-dom'; +import Typography from '@mui/material/Typography'; +// import iAmSmartICon from 'assets/images/icons/icon_iAmSmart.png'; +// import banner from 'assets/images/bg_ml.jpg'; +import { Stack } from '../../../node_modules/@mui/material/index'; +import { useEffect, useState } from 'react'; +import { useParams } from 'react-router-dom'; +import axios from 'axios'; +import { GET_VERIFY_USER_ACCOUNT } from 'utils/ApiPathConst'; +import Loadable from 'components/Loadable'; +import { lazy } from 'react'; + +const LoadingComponent = Loadable(lazy(() => import('../extra-pages/LoadingComponent'))); +const AuthWrapper = Loadable(lazy(() => import('./AuthWrapperCustom'))); +import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline'; +import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined'; + +export default function Verify() { + + const [isLoading, setIsLoading] = useState(true) + const [verifyState, setVerifyState] = useState(null) + + const params = useParams() + const handleVerify = async () => { + const response = await axios.get(GET_VERIFY_USER_ACCOUNT, { + params: { + email: decodeURIComponent(params.email), + emailVerifyHash: decodeURIComponent(params.verifyCode) + } + }) + if (response.status === 200 && response.data) { + setVerifyState(true) + } else { + setVerifyState(false) + } + setIsLoading(false) + } + + let enterUseEffect = false + useEffect(() => { + if (enterUseEffect) handleVerify() + enterUseEffect = true + }, []) + + return ( + + + {isLoading || verifyState == null ? + : + + {verifyState ? + // SUCCESS page + + + 帳戶已成功驗證。 + + + : + // ERROR page + + {/* */} + + 驗證失敗,請聯絡相關的系統管理員協助。 + + + } + + } + + + ) +} \ No newline at end of file diff --git a/src/pages/authentication/auth-forms/PasswordAlertDialog.js b/src/pages/authentication/auth-forms/PasswordAlertDialog.js index 60ef811..adea767 100644 --- a/src/pages/authentication/auth-forms/PasswordAlertDialog.js +++ b/src/pages/authentication/auth-forms/PasswordAlertDialog.js @@ -18,42 +18,47 @@ import { import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined'; const PasswordAlertDialog = (props) => { + console.log(props) return ( - - - - - {props.errorMassage==='ACCOUNT_LOCKED_ERROR'? - - - 帳戶將被封鎖 - - - 帳戶連續五次登入錯誤,請與系統管理員聯絡 - - : - - 用戶名或密碼錯誤 - - } - - - - - {""} - - - - - - + > + + + + {props.errorMassage === 'ACCOUNT_LOCKED_ERROR' ? + + + 帳戶將被封鎖 + + + 帳戶連續五次登入錯誤,請與系統管理員聯絡 + + : + props.errorMassage === 'ACCOUNT_VERIFIED_ERROR' ? + + 帳戶尚未驗證 + : + + 用戶名或密碼錯誤 + + } + + + + + {""} + + + + + + ); }; diff --git a/src/routes/LoginRoutes.js b/src/routes/LoginRoutes.js index a7b48af..30052b9 100644 --- a/src/routes/LoginRoutes.js +++ b/src/routes/LoginRoutes.js @@ -12,6 +12,7 @@ const RegisterForm = Loadable(lazy(() => import('pages/authentication/Register') const BusRegisterForm = Loadable(lazy(() => import('pages/authentication/BusRegister'))); const ErrorPage = Loadable(lazy(() => import('pages/extra-pages/ErrorPage'))); const TestMailPage = Loadable(lazy(() => import('pages/pnspsNotifyTest'))); +const VerifyPage = Loadable(lazy(() => import('pages/authentication/Verify'))); // ==============================|| AUTH ROUTING ||============================== // @@ -42,6 +43,10 @@ const LoginRoutes = { { path: 'testMailPage', element: + }, + { + path: 'verify/:verifyCode/:email', + element: } ] }; diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index b6523a6..b90fce1 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -45,6 +45,7 @@ export const POST_CAPTCHA = apiPath+'/captcha'; export const POST_PUBLIC_USER_REGISTER = apiPath+'/user/register'; export const GET_USERNAME = apiPath+'/user/username'; export const GET_USER_EMAIL = apiPath+'/user/email'; +export const GET_VERIFY_USER_ACCOUNT = apiPath+'/user/verifyEmail'; //Public export const GET_PUBLIC_ORG_USER_LIST = apiPath+'/user/listOrg';