Przeglądaj źródła

move iAM Smart api path to properties

CR003
Anna Ho 1 rok temu
rodzic
commit
dedcbf29bd
5 zmienionych plików z 82 dodań i 55 usunięć
  1. +0
    -13
      src/auth/utils.js
  2. +3
    -0
      src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js
  3. +39
    -21
      src/pages/authentication/RegisterCustom.js
  4. +37
    -21
      src/pages/authentication/auth-forms/AuthLoginCustom.js
  5. +3
    -0
      src/utils/ApiPathConst.js

+ 0
- 13
src/auth/utils.js Wyświetl plik

@@ -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")) {


+ 3
- 0
src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js Wyświetl plik

@@ -313,6 +313,9 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => {
return;
}
formik.setFieldValue("idDocType", newValue.type);
if (newValue.type !== "HKID") {
formik.setFieldValue("checkDigit", "")
}
},
form: formik
})}


+ 39
- 21
src/pages/authentication/RegisterCustom.js Wyświetl plik

@@ -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 (


+ 37
- 21
src/pages/authentication/auth-forms/AuthLoginCustom.js Wyświetl plik

@@ -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;
}
});

}



+ 3
- 0
src/utils/ApiPathConst.js Wyświetl plik

@@ -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';


Ładowanie…
Anuluj
Zapisz