| @@ -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, iAmSmartAppPath, clientId, getBowserType, isAppBowser, iAmSmartCallbackPath} from 'auth/utils' | |||
| import { iAmSmartPath, clientId, getBowserType, isAppBowser, iAmSmartCallbackPath} from 'auth/utils' | |||
| import * as React from 'react'; | |||
| import {FormattedMessage, useIntl} from "react-intl"; | |||
| @@ -48,20 +48,17 @@ const RegisterCustom = () => { | |||
| } | |||
| const openApp = () => { | |||
| setTimeout(function () { | |||
| openQR(); | |||
| }, 1000); | |||
| let callbackUrl = "https://" + iAmSmartCallbackPath() + "/iamsmart/registrycallback"; | |||
| let url = iAmSmartAppPath + "auth" | |||
| 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=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=url; | |||
| +"&brokerPage=true" | |||
| window.location.assign(url); | |||
| } | |||
| return ( | |||
| @@ -6,7 +6,8 @@ import React, { | |||
| import { Link as RouterLink } from 'react-router-dom'; | |||
| import { useNavigate } from 'react-router-dom'; | |||
| import { useForm, } from 'react-hook-form' | |||
| import { iAmSmartPath, iAmSmartAppPath, clientId, getBowserType, isAppBowser, iAmSmartCallbackPath } from 'auth/utils' | |||
| import { iAmSmartPath, clientId, getBowserType, isAppBowser, iAmSmartCallbackPath } from 'auth/utils' | |||
| //iAmSmartAppPath | |||
| // material-ui | |||
| import { | |||
| @@ -196,8 +197,23 @@ const AuthLoginCustom = () => { | |||
| // setTimeout(function () { | |||
| // openQR(); | |||
| // }, 1000); | |||
| // let callbackUrl = "https://" + iAmSmartCallbackPath() + "/iamsmart/authcallback"; | |||
| // let source = getBowserType() | |||
| // console.log(source) | |||
| // let url = iAmSmartAppPath + "auth" | |||
| // + "?clientID=" + clientId | |||
| // + "&responseType=code" | |||
| // + "&source=" + getBowserType() | |||
| // + "&redirectURI=" + encodeURIComponent(callbackUrl) | |||
| // + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") | |||
| // + "&lang=zh-HK"//en-US, zh-HK, or zh-CN | |||
| // //+"&state=" | |||
| // + "&brokerPage=true" | |||
| // window.location=url; | |||
| let callbackUrl = "https://" + iAmSmartCallbackPath() + "/iamsmart/authcallback"; | |||
| let url = iAmSmartAppPath + "auth" | |||
| let url = iAmSmartPath + "/api/v1/auth/getQR" | |||
| + "?clientID=" + clientId | |||
| + "&responseType=code" | |||
| + "&source=" + getBowserType() | |||
| @@ -205,8 +221,9 @@ const AuthLoginCustom = () => { | |||
| + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") | |||
| + "&lang=zh-HK"//en-US, zh-HK, or zh-CN | |||
| //+"&state=" | |||
| + "&brokerPage=false" | |||
| window.location=url; | |||
| + "&brokerPage=true" | |||
| window.location=url; | |||
| } | |||
| @@ -27,7 +27,7 @@ const Index = () => { | |||
| let params = new URLSearchParams(window.location.search) | |||
| if(params.get("code")){ | |||
| HttpUtils.post({ | |||
| url: UrlUtils.GET_SMART_LOGIN, | |||
| url: UrlUtils.GET_SMART_DIRECT_LOGIN, | |||
| params:{ | |||
| code: params.get("code") | |||
| }, | |||
| @@ -1,72 +0,0 @@ | |||
| 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("/login"); | |||
| }, | |||
| onError:()=>{ | |||
| window.location.assign("/login"); | |||
| } | |||
| }); | |||
| } | |||
| } | |||
| return ( | |||
| <LoadingComponent /> | |||
| ); | |||
| }; | |||
| export default Index; | |||
| @@ -12,7 +12,7 @@ const RegisterForm = Loadable(lazy(() => import('pages/authentication/Register') | |||
| const BusRegisterForm = Loadable(lazy(() => import('pages/authentication/BusRegister'))); | |||
| const IAmSmartRegister = Loadable(lazy(() => import('pages/authentication/IAmSmartRegister'))); | |||
| const ErrorPage = Loadable(lazy(() => import('pages/extra-pages/ErrorPage'))); | |||
| //const IAmSmart_DirectLoginCallback = Loadable(lazy(() => import('pages/iAmSmart/DirectLoginCallback'))); | |||
| const IAmSmart_DirectLoginCallback = Loadable(lazy(() => import('pages/iAmSmart/DirectLoginCallback'))); | |||
| //const IAmSmart_FallCallback = Loadable(lazy(() => import('pages/iAmSmart/FallCallback'))); | |||
| const IAmSmart_FailCallback = Loadable(lazy(() => import('pages/iAmSmart/FailCallback'))); | |||
| const IAmSmart_SuccessCallback = Loadable(lazy(() => import('pages/iAmSmart/SuccessCallback'))); | |||
| @@ -61,7 +61,7 @@ const LoginRoutes = { | |||
| }, | |||
| { | |||
| path: 'iamsmart/logincallback', | |||
| element: <IAmSmart_AuthCallback/> | |||
| element: <IAmSmart_DirectLoginCallback/> | |||
| }, | |||
| { | |||
| path: 'iamsmart/loginfallback', | |||
| @@ -124,6 +124,7 @@ export const DELETE_EMAIL = apiPath+'/email/delete'; | |||
| //iAmSmart | |||
| export const GET_SMART_PROFILE = apiPath+'/smart/getProfile'; //POST | |||
| export const GET_SMART_LOGIN = apiPath+'/smart/login'; //POST | |||
| export const GET_SMART_DIRECT_LOGIN = apiPath+'/smart/directLogin'; //POST | |||
| //gen report | |||