Pārlūkot izejas kodu

iamsmart login

master
Anna Ho pirms 1 gada
vecāks
revīzija
5ebe4ee01e
9 mainītis faili ar 88 papildinājumiem un 9 dzēšanām
  1. +3
    -1
      src/auth/utils.js
  2. +4
    -0
      src/pages/authentication/IAmSmartRegister.js
  3. +18
    -2
      src/pages/authentication/auth-forms/AuthLoginCustom.js
  4. +6
    -4
      src/pages/authentication/auth-forms/IAmSmartFormWizard.js
  5. +1
    -1
      src/pages/iAmSmart/AuthCallback/index.js
  6. +43
    -0
      src/pages/iAmSmart/RegistryCallback/index.js
  7. +5
    -0
      src/routes/LoginRoutes.js
  8. +6
    -0
      src/themes/palette.js
  9. +2
    -1
      src/utils/ApiPathConst.js

+ 3
- 1
src/auth/utils.js Parādīt failu

@@ -18,8 +18,10 @@ export const clientId = "cf61fa7c121e4869966f69c8694b1cd2";

export const iAmSmartCallbackPath = () => {
let hostname = window.location.hostname;
if (hostname.match("localhost")) {
if (hostname.match("pnspsuat")) {
hostname = "pnspsuat.gld.gov.hk";
}else{
hostname = "pnspsdev.gld.gov.hk";
}
return hostname;
};


+ 4
- 0
src/pages/authentication/IAmSmartRegister.js Parādīt failu

@@ -83,6 +83,10 @@ const Register = () => {
}

const handleNext = async () => {
if(!idNo){
notifyActionError("資料,請返回注冊頁面。")
return;
}
const test = await handleCheckID()
if (test) {
notifyActionError("此用戶已注冊,請返回登入頁面並進行登入流程。")


+ 18
- 2
src/pages/authentication/auth-forms/AuthLoginCustom.js Parādīt failu

@@ -6,6 +6,7 @@ import React, {
import { Link as RouterLink } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { useForm, } from 'react-hook-form'
import { iAmSmartPath, clientId, getBowerType , iAmSmartCallbackPath} from 'auth/utils'

// material-ui
import {
@@ -167,6 +168,21 @@ const AuthLoginCustom = () => {

const { handleSubmit } = useForm({})

const getQRWithIAmSmart = () => {
let callbackUrl = "https://"+iAmSmartCallbackPath()+"/iamsmart/authcallback";
let url = iAmSmartPath + "/api/v1/auth/getQR"
+ "?clientID=" + clientId
+ "&responseType=code"
+"&source=" + getBowerType()
+"&redirectURI="+encodeURIComponent(callbackUrl)
+"&scope="+encodeURIComponent("eidapi_auth eidapi_profiles")
+"&lang=zh-HK"//en-US, zh-HK, or zh-CN
//+"&state="
+"&brokerPage=false"
window.location.assign(url);
}


return (
<FormikProvider value={formik}>
<form onSubmit={handleSubmit(tryLogin)}>
@@ -261,12 +277,12 @@ const AuthLoginCustom = () => {
</Grid>
<Grid item xs={12}>
<Stack direction="row" justifyContent="space-between" alignItems="center" spacing={2}>
<Button fullWidth size="large" variant="outlined" startIcon={<img src={iAmSmartICon} alt="iAM Smart" width="30" />}><Typography variant="h5">智方便登入</Typography></Button>
<Button onClick={()=>getQRWithIAmSmart()} color="iAmSmart" fullWidth size="large" variant="outlined" startIcon={<img src={iAmSmartICon} alt="iAM Smart" width="30" />}><Typography variant="h5">智方便登入</Typography></Button>
</Stack>
</Grid>
<Grid item xs={12}>
<Stack direction="row" justifyContent="space-between" alignItems="center" spacing={2}>
<Link href="#"><Typography align="center" variant="h6">了解更多智方便</Typography></Link>
<Link href="https://www.iamsmart.gov.hk/tc/"><Typography align="center" variant="h6">{"了解更多 >"}</Typography></Link>
</Stack>
</Grid>
<Grid item xs={12}>


+ 6
- 4
src/pages/authentication/auth-forms/IAmSmartFormWizard.js Parādīt failu

@@ -75,8 +75,6 @@ const CustomFormWizard = (props) => {
+ "授權,否則嚴禁複製、改編、分發、發布或向公眾提供該等版權作品。"


const dataStr = "{\"emailAddress\":\"[email protected]\",\"postalAddress\":{\"EngPremisesAddress\":{\"EngDistrict\":{\"DcDistrict\":\"KC\",\"Sub-district\":\"TSING YI\"},\"EngEstate\":{\"EstateName\":\"Cheung Hang Estate\",\"EngPhase\":{\"PhaseName\":\"N/A\"}},\"BuildingName\":\"Hang Lai House\",\"EngBlock\":{\"BlockDescriptor\":\"Block\",\"BlockNo\":\"2\"},\"Region\":\"NT\",\"EngStreet\":{\"StreetName\":\"Liu To Road\",\"BuildingNoFrom\":\"6\"},\"Eng3dAddress\":{\"EngFloor\":{\"FloorNum\":\"33\"},\"EngUnit\":{\"UnitDescriptor\":\"Room\",\"UnitNo\":\"3301\"}}}},\"mobileNumber\":{\"CountryCode\":\"852\",\"SubscriberNumber\":\"99999999\"},\"residentialAddress\":{\"ChiPremisesAddress\":{\"Chi3dAddress\":{\"ChiUnit\":{\"UnitDescriptor\":\"室\",\"UnitNo\":\"1010\"},\"ChiFloor\":{\"FloorNum\":\"10\"}},\"ChiBlock\":{\"BlockDescriptor\":\"座\",\"BlockNo\":\"2\"},\"BuildingName\":\"亨麗樓(第2座)\",\"ChiDistrict\":{\"DcDistrict\":\"KC\",\"Sub-district\":\"青衣\"},\"Region\":\"新界\",\"ChiEstate\":{\"EstateName\":\"長亨邨\"},\"ChiStreet\":{\"StreetName\":\"寮肚路\",\"BuildingNoFrom\":\"6\"}}},\"enName\":{\"UnstructuredName\":\"Testing Co One\"},\"idNo\":{\"Identification\":\"G561107\",\"CheckDigit\":\"4\"},\"chName\":{\"ChineseName\":\"測試商一\"}}";

useEffect(() => {
location.state?.responseData ?? {}
onCaptchaChange();
@@ -84,7 +82,8 @@ const CustomFormWizard = (props) => {
}, []);

const responseToData = () => {
let rd = JSON.parse(dataStr);
//let rd = JSON.parse("{\"emailAddress\":\"[email protected]\",\"postalAddress\":{\"EngPremisesAddress\":{\"EngDistrict\":{\"DcDistrict\":\"KC\",\"Sub-district\":\"TSING YI\"},\"EngEstate\":{\"EstateName\":\"Cheung Hang Estate\",\"EngPhase\":{\"PhaseName\":\"N/A\"}},\"BuildingName\":\"Hang Lai House\",\"EngBlock\":{\"BlockDescriptor\":\"Block\",\"BlockNo\":\"2\"},\"Region\":\"NT\",\"EngStreet\":{\"StreetName\":\"Liu To Road\",\"BuildingNoFrom\":\"6\"},\"Eng3dAddress\":{\"EngFloor\":{\"FloorNum\":\"33\"},\"EngUnit\":{\"UnitDescriptor\":\"Room\",\"UnitNo\":\"3301\"}}}},\"mobileNumber\":{\"CountryCode\":\"852\",\"SubscriberNumber\":\"99999999\"},\"residentialAddress\":{\"ChiPremisesAddress\":{\"Chi3dAddress\":{\"ChiUnit\":{\"UnitDescriptor\":\"室\",\"UnitNo\":\"1010\"},\"ChiFloor\":{\"FloorNum\":\"10\"}},\"ChiBlock\":{\"BlockDescriptor\":\"座\",\"BlockNo\":\"2\"},\"BuildingName\":\"亨麗樓(第2座)\",\"ChiDistrict\":{\"DcDistrict\":\"KC\",\"Sub-district\":\"青衣\"},\"Region\":\"新界\",\"ChiEstate\":{\"EstateName\":\"長亨邨\"},\"ChiStreet\":{\"StreetName\":\"寮肚路\",\"BuildingNoFrom\":\"6\"}}},\"enName\":{\"UnstructuredName\":\"Testing Co One\"},\"idNo\":{\"Identification\":\"G561107\",\"CheckDigit\":\"4\"},\"chName\":{\"ChineseName\":\"測試商一\"}}");
let rd = props.state.responseData;
let data = {
"enName": rd.enName?.UnstructuredName ?? "",
"chName": rd.chName?.ChineseName ?? "",
@@ -394,7 +393,7 @@ const CustomFormWizard = (props) => {
</div>

<Typography mt={0.25} variant="h6" sx={{ color: '#f10000' }}>註有*的項目必須輸入資料。</Typography>
<Stack mt={1} direction="row" style={{ alignItems: "center" }}><img src={iAmSmartICon} alt="iAM Smart" width="30" /><Typography mt={0.25} variant="h6" >: 表示該項由「智方便」提供。</Typography></Stack>
<Stack mt={1} direction="row" style={{ alignItems: "center" }}><img src={iAmSmartICon} alt="iAM Smart" width="25" /><Typography mt={0.25} variant="h6" >: 表示該項由「智方便」提供。</Typography></Stack>

</Stack>
</Grid>
@@ -441,6 +440,7 @@ const CustomFormWizard = (props) => {
<Typography variant="h5">
地址
<span style={{ color: '#f10000' }}>*</span>
{iAmSmartData.address1?<img src={iAmSmartICon} alt="iAM Smart" width="25" />:null}
</Typography>
</InputLabel>
<OutlinedInput
@@ -557,6 +557,7 @@ const CustomFormWizard = (props) => {
<Typography variant="h5">
電郵
<span style={{ color: '#f10000' }}>*</span>
{iAmSmartData.email?<img src={iAmSmartICon} alt="iAM Smart" width="25" />:null}
</Typography>
</InputLabel>
<OutlinedInput
@@ -635,6 +636,7 @@ const CustomFormWizard = (props) => {
<Typography variant="h5">
聯絡電話
<span style={{ color: '#f10000' }}>*</span>
{iAmSmartData.phone?<img src={iAmSmartICon} alt="iAM Smart" width="25" />:null}
</Typography>
</InputLabel>
<Stack direction="row">


+ 1
- 1
src/pages/iAmSmart/AuthCallback/index.js Parādīt failu

@@ -21,7 +21,7 @@ const Index = () => {
let params = new URLSearchParams(window.location.search)
if(params.get("code")){
HttpUtils.post({
url: UrlUtils.GET_SMART_PROFILE,
url: UrlUtils.GET_SMART_LOGIN,
params:{
code: params.get("code")
},


+ 43
- 0
src/pages/iAmSmart/RegistryCallback/index.js Parādīt failu

@@ -0,0 +1,43 @@

import * as React from "react";
import * as HttpUtils from "utils/HttpUtils";
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')));


// ==============================|| DASHBOARD - DEFAULT ||============================== //

const Index = () => {

const navigate = useNavigate()

React.useEffect(() => {
getPrfile();
}, []);

function getPrfile(){
let params = new URLSearchParams(window.location.search)
if(params.get("code")){
HttpUtils.post({
url: UrlUtils.GET_SMART_PROFILE,
params:{
code: params.get("code")
},
onSuccess: (responseData) => {
navigate('/iAmSmartRegisterFrom', { state: { responseData: responseData } });
}
});
}
}



return (
<LoadingComponent />
);
};

export default Index;

+ 5
- 0
src/routes/LoginRoutes.js Parādīt failu

@@ -15,6 +15,7 @@ const ErrorPage = Loadable(lazy(() => import('pages/extra-pages/ErrorPage')));
const IAmSmart_FailCallback = Loadable(lazy(() => import('pages/iAmSmart/FailCallback')));
const IAmSmart_SuccessCallback = Loadable(lazy(() => import('pages/iAmSmart/SuccessCallback')));
const IAmSmart_AuthCallback = Loadable(lazy(() => import('pages/iAmSmart/AuthCallback')));
const IAmSmart_RegistryCallback = Loadable(lazy(() => import('pages/iAmSmart/RegistryCallback')));

//TODO: this page for testing only, please remove at prod
const TestMailPage = Loadable(lazy(() => import('pages/pnspsNotifyTest')));
@@ -58,6 +59,10 @@ const LoginRoutes = {
path: 'iamsmart/authcallback',
element: <IAmSmart_AuthCallback/>
},
{
path: 'iamsmart/registrycallback',
element: <IAmSmart_RegistryCallback/>
},
{
path: 'iamsmart/loginfallback',
element: <IAmSmart_FailCallback/>


+ 6
- 0
src/themes/palette.js Parādīt failu

@@ -83,6 +83,12 @@ const Palette = (mode) => {
dark: '#b0671e',
contrastText: '#fff',
},
iAmSmart: {
main: '#2B7366',
light: '#ff5e5e',
dark: '#b0671e',
contrastText: '#fff',
},
backgroundColor: {
default: '#F2F2F2'
}


+ 2
- 1
src/utils/ApiPathConst.js Parādīt failu

@@ -106,4 +106,5 @@ export const POST_EMAIL_SAVE = apiPath+'/email/save';
export const DELETE_EMAIL = apiPath+'/email/delete';

//iAmSmart
export const GET_SMART_PROFILE = apiPath+'smart/getProfile'; //POST
export const GET_SMART_PROFILE = apiPath+'smart/getProfile'; //POST
export const GET_SMART_LOGIN = apiPath+'smart/login'; //POST

Notiek ielāde…
Atcelt
Saglabāt