diff --git a/src/auth/utils.js b/src/auth/utils.js index 80d5aef..91703d7 100644 --- a/src/auth/utils.js +++ b/src/auth/utils.js @@ -14,19 +14,6 @@ export const paymentPath = window.location.href.match("localhost:3000") ? `${hos export const delBugMode = true; -/** - * Testing: - * Domain: apigw-isit.staging-eid.gov.hk - * URL: hk.gov.iamsmart.testapp:// - * - * Production - * Domain: apigw.iamsmart.gov.hk - * URL: hk.gov.iamsmart:// - */ -export const iAmSmartPath = `https://apigw-isit.staging-eid.gov.hk`; -export const iAmSmartAppPath = `hk.gov.iamsmart.testapp://`; -export const clientId = "cf61fa7c121e4869966f69c8694b1cd2"; - export const iAmSmartCallbackPath = () => { let hostname = window.location.hostname; if (hostname.match("pnspsuat")) { diff --git a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js index f840521..dcbe535 100644 --- a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js +++ b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js @@ -313,6 +313,9 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => { return; } formik.setFieldValue("idDocType", newValue.type); + if (newValue.type !== "HKID") { + formik.setFieldValue("checkDigit", "") + } }, form: formik })} diff --git a/src/pages/authentication/RegisterCustom.js b/src/pages/authentication/RegisterCustom.js index b3a7046..a185ba2 100644 --- a/src/pages/authentication/RegisterCustom.js +++ b/src/pages/authentication/RegisterCustom.js @@ -8,9 +8,12 @@ import { import Typography from '@mui/material/Typography'; import banner from 'assets/images/bg_ml.jpg'; import { Stack } from '../../../node_modules/@mui/material/index'; -import { iAmSmartPath, clientId, getBowserType, isAppBowser, iAmSmartCallbackPath } from 'auth/utils' +import { getBowserType, isAppBowser, iAmSmartCallbackPath } from 'auth/utils' import { IAmSmartButton } from "components/iAmSmartButton"; +import * as HttpUtils from "utils/HttpUtils"; +import { I_AM_SMART_PATH } from "utils/ApiPathConst"; + import * as React from 'react'; import { FormattedMessage, useIntl } from "react-intl"; @@ -36,30 +39,45 @@ const RegisterCustom = () => { const openQR = () => { let callbackUrl = "https://" + iAmSmartCallbackPath() + "/iamsmart/registrycallback"; - let url = iAmSmartPath + "/api/v1/auth/getQR" - + "?clientID=" + clientId - + "&responseType=code" - + "&source=" + getBowserType() - + "&redirectURI=" + encodeURIComponent(callbackUrl) - + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") - + "&lang=" + (locale === 'en' ? "en-US" : locale === 'zh-HK' ? "zh-HK" : "zh-CN") - //+"&state=" - + "&brokerPage=false" - window.location.assign(url); + + HttpUtils.get({ + url: I_AM_SMART_PATH, + onSuccess: (responseData) => { + let url = responseData.iAmSmartPath + "/api/v1/auth/getQR" + + "?clientID=" + responseData.ci + + "&responseType=code" + + "&source=" + getBowserType() + + "&redirectURI=" + encodeURIComponent(callbackUrl) + + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") + + "&lang=" + (locale === 'en' ? "en-US" : locale === 'zh-HK' ? "zh-HK" : "zh-CN") + //+"&state=" + + "&brokerPage=false" + window.location.assign(url); + } + }); + + } const openApp = () => { + //not support open app, just call QR link let callbackUrl = "https://" + iAmSmartCallbackPath() + "/iamsmart/registrycallback"; - let url = iAmSmartPath + "/api/v1/auth/getQR" - + "?clientID=" + clientId - + "&responseType=code" - + "&source=" + getBowserType() - + "&redirectURI=" + encodeURIComponent(callbackUrl) - + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") - + "&lang=" + (locale === 'en' ? "en-US" : locale === 'zh-HK' ? "zh-HK" : "zh-CN") - //+"&state=" - + "&brokerPage=true" - window.location.assign(url); + + HttpUtils.get({ + url: I_AM_SMART_PATH, + onSuccess: (responseData) => { + let url = responseData.iAmSmartPath + "/api/v1/auth/getQR" + + "?clientID=" + responseData.ci + + "&responseType=code" + + "&source=" + getBowserType() + + "&redirectURI=" + encodeURIComponent(callbackUrl) + + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") + + "&lang=" + (locale === 'en' ? "en-US" : locale === 'zh-HK' ? "zh-HK" : "zh-CN") + //+"&state=" + + "&brokerPage=false" + window.location.assign(url); + } + }); } return ( diff --git a/src/pages/authentication/auth-forms/AuthLoginCustom.js b/src/pages/authentication/auth-forms/AuthLoginCustom.js index 4187a3e..82e2acd 100644 --- a/src/pages/authentication/auth-forms/AuthLoginCustom.js +++ b/src/pages/authentication/auth-forms/AuthLoginCustom.js @@ -7,7 +7,11 @@ import { import { Link as RouterLink } from 'react-router-dom'; import { useNavigate } from 'react-router-dom'; import { useForm, } from 'react-hook-form' -import { iAmSmartPath, clientId, getBowserType, isAppBowser, iAmSmartCallbackPath } from 'auth/utils' +import { getBowserType, isAppBowser, iAmSmartCallbackPath } from 'auth/utils' + +import * as HttpUtils from "utils/HttpUtils"; +import { I_AM_SMART_PATH } from "utils/ApiPathConst"; + //iAmSmartAppPath // material-ui @@ -214,16 +218,23 @@ const AuthLoginCustom = () => { const openQR = () => { let callbackUrl = "https://" + iAmSmartCallbackPath() + "/iamsmart/authcallback"; - let url = iAmSmartPath + "/api/v1/auth/getQR" - + "?clientID=" + clientId - + "&responseType=code" - + "&source=" + getBowserType() - + "&redirectURI=" + encodeURIComponent(callbackUrl) - + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") - + "&lang=" + (locale === 'en' ? "en-US" : locale === 'zh-HK' ? "zh-HK" : "zh-CN") - //+"&state=" - + "&brokerPage=false" - window.location = url; + + HttpUtils.get({ + url: I_AM_SMART_PATH, + onSuccess: (responseData) => { + let url = responseData.iAmSmartPath + "/api/v1/auth/getQR" + + "?clientID=" + responseData.ci + + "&responseType=code" + + "&source=" + getBowserType() + + "&redirectURI=" + encodeURIComponent(callbackUrl) + + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") + + "&lang=" + (locale === 'en' ? "en-US" : locale === 'zh-HK' ? "zh-HK" : "zh-CN") + //+"&state=" + + "&brokerPage=false" + window.location = url; + } + }); + } const openApp = () => { @@ -246,16 +257,21 @@ const AuthLoginCustom = () => { // window.location=url; let callbackUrl = "https://" + iAmSmartCallbackPath() + "/iamsmart/authcallback"; - let url = iAmSmartPath + "/api/v1/auth/getQR" - + "?clientID=" + clientId - + "&responseType=code" - + "&source=" + getBowserType() - + "&redirectURI=" + encodeURIComponent(callbackUrl) - + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") - + "&lang=" + (locale === 'en' ? "en-US" : locale === 'zh-HK' ? "zh-HK" : "zh-CN") - //+"&state=" - + "&brokerPage=true" - window.location = url; + HttpUtils.get({ + url: I_AM_SMART_PATH, + onSuccess: (responseData) => { + let url = responseData.iAmSmartPath + "/api/v1/auth/getQR" + + "?clientID=" + responseData.ci + + "&responseType=code" + + "&source=" + getBowserType() + + "&redirectURI=" + encodeURIComponent(callbackUrl) + + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") + + "&lang=" + (locale === 'en' ? "en-US" : locale === 'zh-HK' ? "zh-HK" : "zh-CN") + //+"&state=" + + "&brokerPage=false" + window.location = url; + } + }); } diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index 3fa1a32..86f3487 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -10,6 +10,9 @@ export const CHANGE_PASSWORD_PATH = "/user/change-password" export const GET_SYS_PARAMS = apiPath+'/settings'; export const PRIVACY_POLICY_PATH = apiPath+'/privacyPolicy'; +export const I_AM_SMART_PATH = apiPath+'/smart/call/iAmSmart'; +export const I_AM_SMART_APP_PATH = apiPath+'/smart/call/app/iAmSmart'; + //Group Config export const GET_GROUP_LIST_PATH = apiPath+'/group'; export const GET_GROUP_COMBO_PATH = '/group/combo';