diff --git a/src/auth/utils.js b/src/auth/utils.js
index cdc0c7a..2abfd45 100644
--- a/src/auth/utils.js
+++ b/src/auth/utils.js
@@ -33,11 +33,10 @@ export const getNonce = () => {
return hostname;
};
-export const getBowerType = () => {
+export const getBowserType = () => {
console.log(navigator.userAgent)
// const regex = /Mobi|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Mi|huawei|Opera Mini|SAMSUNG|Samsung|SGH-[I|N|T]|GT-[I|N]|SM-[A|N|P|T|Z]|SHV-E|SCH-[I|J|R|S]|SPH-L/i;
// if(!regex.test(navigator.userAgent))
-
if (navigator.userAgent.indexOf("Edg") != -1) {
if (navigator.userAgent.match(/Android/i)) return "Android_Edge"
if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) return "iOS_Edge"
@@ -63,6 +62,10 @@ export const getBowerType = () => {
return "PC_Browser";
}
+export const isAppBowser = () => {
+ return "PC_Browser" != getBowserType();
+}
+
export const isUserLoggedIn = () => {
return localStorage.getItem('userData') && localStorage.getItem(useJwt.jwtConfig.storageTokenKeyName);
diff --git a/src/pages/User/SearchPage_Individual/UserTable_Individual.js b/src/pages/User/SearchPage_Individual/UserTable_Individual.js
index 6e746ac..77e84d4 100644
--- a/src/pages/User/SearchPage_Individual/UserTable_Individual.js
+++ b/src/pages/User/SearchPage_Individual/UserTable_Individual.js
@@ -68,7 +68,9 @@ export default function UserTable_Individual({ recordList }) {
valueGetter: (params) => {
if (params.value) {
let tel = JSON.parse(params.value);
- return "+" + tel.countryCode + " " + tel.phoneNumber;
+ if(tel?.phoneNumber)
+ return "+" + tel?.countryCode + " " + tel?.phoneNumber;
+ else return "";
}
}
diff --git a/src/pages/authentication/RegisterCustom.js b/src/pages/authentication/RegisterCustom.js
index 5298382..5ae50c2 100644
--- a/src/pages/authentication/RegisterCustom.js
+++ b/src/pages/authentication/RegisterCustom.js
@@ -9,7 +9,7 @@ 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 { iAmSmartPath, clientId, getBowerType , iAmSmartCallbackPath} from 'auth/utils'
+import { iAmSmartPath, clientId, getBowserType , iAmSmartCallbackPath} from 'auth/utils'
import * as React from 'react';
@@ -29,7 +29,7 @@ const RegisterCustom = () => {
let url = iAmSmartPath + "/api/v1/auth/getQR"
+ "?clientID=" + clientId
+ "&responseType=code"
- +"&source=" + getBowerType()
+ +"&source=" + getBowserType()
+"&redirectURI="+encodeURIComponent(callbackUrl)
+"&scope="+encodeURIComponent("eidapi_auth eidapi_profiles")
+"&lang=zh-HK"//en-US, zh-HK, or zh-CN
diff --git a/src/pages/authentication/auth-forms/AuthLoginCustom.js b/src/pages/authentication/auth-forms/AuthLoginCustom.js
index 74fe1a8..8db112d 100644
--- a/src/pages/authentication/auth-forms/AuthLoginCustom.js
+++ b/src/pages/authentication/auth-forms/AuthLoginCustom.js
@@ -6,7 +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'
+import { iAmSmartPath, clientId, getBowserType, isAppBowser, iAmSmartCallbackPath } from 'auth/utils'
// material-ui
import {
@@ -169,31 +169,42 @@ const AuthLoginCustom = () => {
const { handleSubmit } = useForm({})
const getQRWithIAmSmart = () => {
- let callbackUrl = "https://"+iAmSmartCallbackPath()+"/iamsmart/authcallback";
+ if (isAppBowser()) {
+ openApp();
+ } else {
+ openQR();
+ }
+ }
+
+ const openQR = () => {
+ 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
+ + "&source=" + getBowserType()
+ + "&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);
+ + "&brokerPage=false"
+ window.location=url;
}
const openApp = () => {
- let callbackUrl = "https://"+iAmSmartCallbackPath()+"/iamsmart/authcallback";
- let url = "hk.gov.iamsmart.testapp://" +"auth"
+ setTimeout(function () {
+ openQR();
+ }, 1000);
+ let callbackUrl = "https://" + iAmSmartCallbackPath() + "/iamsmart/authcallback";
+ let url = "hk.gov.iamsmart.testapp://" + "auth"
+ "?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
+ + "&source=" + getBowserType()
+ + "&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);
+ + "&brokerPage=false"
+ window.location=url;
}
@@ -291,12 +302,7 @@ const AuthLoginCustom = () => {
-
-
-
-
-
-
+
diff --git a/src/pages/iAmSmart/FallCallback/index.js b/src/pages/iAmSmart/FallCallback/index.js
new file mode 100644
index 0000000..790f0f0
--- /dev/null
+++ b/src/pages/iAmSmart/FallCallback/index.js
@@ -0,0 +1,72 @@
+
+import * as React from "react";
+import * as HttpUtils from "utils/HttpUtils";
+import * as UrlUtils from "utils/ApiPathConst";
+import { useNavigate } from "react-router-dom";
+import { useDispatch } from "react-redux";
+import { handleLogoutFunction, handleLogin } from 'auth/index';
+
+import Loadable from 'components/Loadable';
+const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
+
+
+// ==============================|| DASHBOARD - DEFAULT ||============================== //
+
+const Index = () => {
+
+ const dispatch = useDispatch()
+ const navigate = useNavigate()
+
+ React.useEffect(() => {
+ getPrfile();
+ }, []);
+
+ function getPrfile(){
+ dispatch(handleLogoutFunction());
+
+ let params = new URLSearchParams(window.location.search)
+ if(params.get("code")){
+ HttpUtils.post({
+ url: UrlUtils.GET_SMART_LOGIN,
+ params:{
+ code: params.get("code")
+ },
+ onSuccess: (responseData) => {
+
+ //navigate('/iAmSmartRegisterFrom', { state: { responseData: responseData } });
+
+ console.log(response)
+ const userData = {
+ id: responseData.id,
+ fullenName: responseData.name,
+ fullchName: responseData.chName,
+ email: responseData.email,
+ type: responseData.type,
+ role: responseData.role,
+ abilities: responseData.abilities,
+ creditor: responseData.creditor,
+ //avatar: require('src/assets/images/users/avatar-3.png').default,
+ }
+ const data = { ...userData, accessToken: responseData.accessToken, refreshToken: responseData.refreshToken }
+ // setSuccess(true)
+ dispatch(handleLogin(data))
+ navigate('/dashboard');
+ location.reload()
+
+ },
+ onFail: ()=>{
+ window.location.assign("/iamsmart/loginFall");
+ },
+ onError:()=>{
+ window.location.assign("/iamsmart/loginFall");
+ }
+ });
+ }
+ }
+
+ return (
+
+ );
+};
+
+export default Index;
\ No newline at end of file
diff --git a/src/routes/LoginRoutes.js b/src/routes/LoginRoutes.js
index feca500..2c46693 100644
--- a/src/routes/LoginRoutes.js
+++ b/src/routes/LoginRoutes.js
@@ -55,6 +55,10 @@ const LoginRoutes = {
path: 'error',
element:
},
+ {
+ path: 'iamsmart/fallcallback',
+ element:
+ },
{
path: 'iamsmart/authcallback',
element: