From b71885d1de7c1fd902bec91250113c98b1dc791c Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Wed, 31 Jan 2024 15:26:35 +0800 Subject: [PATCH] fix new password with forgot password and add fps prefix for fpsqrcodeurl --- src/pages/Payment/FPS/FPS.js | 39 ++++++++++++--- .../ForgotPassword/AuthCallback/index.js | 50 +++++++------------ src/utils/ApiPathConst.js | 2 +- 3 files changed, 51 insertions(+), 40 deletions(-) diff --git a/src/pages/Payment/FPS/FPS.js b/src/pages/Payment/FPS/FPS.js index 7de61e8..049e5c7 100644 --- a/src/pages/Payment/FPS/FPS.js +++ b/src/pages/Payment/FPS/FPS.js @@ -46,6 +46,7 @@ const Index = () => { const [paymentId, setPaymentId] = React.useState(""); const [fpsqrcodeurl, setFpsqrcodeurl] = React.useState(""); const [fpsqrcodeurlPrd, setFpsqrcodeurlPrd] = React.useState(""); + const [fpsqrcodeurlFps, setFpsqrcodeurlFps] = React.useState(""); const [browserType, setBrowserType] = React.useState(""); const mobileBrowser = "Mobile"; const desktopBrowser = "Desktop"; @@ -119,16 +120,21 @@ const Index = () => { // setFpsmerchanttimeoutdatetime(convertedDateString) // setPaymentid("C202310268000681") // setPaymentstatuscode("APPR") + const webtoken = paymentData.webtoken; + const transactionid = paymentData.transactionid; + console.log(webtoken) + console.log(transactionid) localStorage.removeItem("transactionid") localStorage.removeItem("webtoken") - localStorage.setItem("transactionid", paymentData.transactionid) - localStorage.setItem("webtoken", paymentData.webtoken) + localStorage.setItem("transactionid", transactionid) + localStorage.setItem("webtoken", webtoken) + HttpUtils.post({ url: paymentPath+loadPaymentUrl, params:{ - "transactionid": paymentData.transactionid, - "webtoken": paymentData.webtoken, + "transactionid": transactionid, + "webtoken": webtoken, "paymentmethod":"04,BCFP,FPS", "order": { "totalamount":paymentData.amount, @@ -169,13 +175,20 @@ const Index = () => { const parsedUrl = new URL(responseData.fpsqrcodeurl); const fpsqrcodeurl = "https://"+window.location.hostname+'/payment'+parsedUrl.pathname; + const fpsqrcodeurlwithFps = "https://"+"fps."+window.location.hostname+'/payment'+parsedUrl.pathname; + console.log(parsedUrl) + console.log(fpsqrcodeurl) + console.log(fpsqrcodeurlwithFps) const openPASGUrl = pasgPath + '?pay_req_obj=' + encodeURIComponent(fpsqrcodeurl) + '&callback=' - + encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?TRANSACTION_ID='+paymentData.transactionid+"&WEB_TOKEN="+paymentData.webtoken+"&PAYMENT_ID="+localStorage.getItem("paymentId")); + + encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?TRANSACTION_ID='+transactionid+"&WEB_TOKEN="+webtoken+"&PAYMENT_ID="+localStorage.getItem("paymentId")); const openPASGUrlPrd = pasgPathPrd + '?pay_req_obj=' + encodeURIComponent(fpsqrcodeurl) + '&callback=' - + encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?TRANSACTION_ID='+paymentData.transactionid+"&WEB_TOKEN="+paymentData.webtoken+"&PAYMENT_ID="+localStorage.getItem("paymentId")); + + encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?TRANSACTION_ID='+transactionid+"&WEB_TOKEN="+webtoken+"&PAYMENT_ID="+localStorage.getItem("paymentId")); + const openPASGUrlPrdFps = pasgPath + '?pay_req_obj=' + encodeURIComponent(fpsqrcodeurlwithFps) + '&callback=' + + encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?TRANSACTION_ID='+transactionid+"&WEB_TOKEN="+webtoken+"&PAYMENT_ID="+localStorage.getItem("paymentId")); setFpsqrcodeurl(openPASGUrl) setFpsqrcodeurlPrd(openPASGUrlPrd) + setFpsqrcodeurlFps(openPASGUrlPrdFps) } }); @@ -254,6 +267,10 @@ const Index = () => { window.location.assign(fpsqrcodeurlPrd); } + const mobliePaymentFps = ()=>{ + window.location.assign(fpsqrcodeurlFps); + } + return ( !onReady ? @@ -308,6 +325,16 @@ const Index = () => { }} sx={{ m: 4 }} >請選擇支付程式付款-PRD + : diff --git a/src/pages/authentication/ForgotPassword/AuthCallback/index.js b/src/pages/authentication/ForgotPassword/AuthCallback/index.js index dec6731..62b2d93 100644 --- a/src/pages/authentication/ForgotPassword/AuthCallback/index.js +++ b/src/pages/authentication/ForgotPassword/AuthCallback/index.js @@ -35,6 +35,8 @@ 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 = () => { @@ -46,11 +48,13 @@ const Index = () => { 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) }, []); @@ -75,13 +79,13 @@ const Index = () => { setUsername(response.data.username) setVerifyState(true) } else { - setVerifyState(true) + setVerifyState(false) } setLoding(false) } ).catch(error => { console.log(error) - setVerifyState(true) + setVerifyState(false) setLoding(false) }); @@ -90,16 +94,14 @@ const Index = () => { const goLogin = async (values) =>{ dispatch(handleLogoutFunction()); - console.log(username) - await axios.patch(UrlUtils.PATCH_FORGOT_PASSWORD_NEW_PASSWORD, { - params: { + HttpUtils.post({ + url: UrlUtils.POST_FORGOT_PASSWORD_NEW_PASSWORD, + params:{ username: username, newPassword: values.password - } - }).then( - (response)=>{ - if (response.status === 204) { - useJwt + }, + onSuccess: () => { + useJwt .login({ username: username, password: values.password }) .then((response) => { // console.log(response) @@ -139,28 +141,10 @@ const Index = () => { .catch((error) => { // setSuccess(false) console.error(error) - console.error(error.response.data.error) - setErrorMassage(error.response.data.error) - setOpen(true) + // console.error(error.response.data.error) + // setErrorMassage(error.response.data.error) + // setOpen(true) }); - } else { - setVerifyState(true) - } - 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"); @@ -336,7 +320,7 @@ const Index = () => { name="username" label={intl.formatMessage({id: 'userLoginName'}) + ":"} placeholder={intl.formatMessage({id: 'userLoginName'})} - defaultValue={username} + // defaultValue={username} value={username} disabled={true} /> @@ -420,7 +404,7 @@ const Index = () => { name="confirmPassword" label={intl.formatMessage({id: 'confirmPassword'}) + ":"} placeholder={intl.formatMessage({id: 'confirmPassword'})} - defaultValue={formik.values.confirmPassword.trim()} + // defaultValue={formik.values.confirmPassword.trim()} value={formik.values.confirmPassword.trim()} error={Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword)} onBlur={formik.handleBlur} diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index c458163..4b9487b 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -74,7 +74,7 @@ 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'; +export const POST_FORGOT_PASSWORD_NEW_PASSWORD = apiPath+'/user/forgotPasswordNewPassword'; //Public