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