Browse Source

iAmSmart fix bug

master
Anna Ho 1 year ago
parent
commit
1dc1465fe5
6 changed files with 34 additions and 91 deletions
  1. +9
    -12
      src/pages/authentication/RegisterCustom.js
  2. +21
    -4
      src/pages/authentication/auth-forms/AuthLoginCustom.js
  3. +1
    -1
      src/pages/iAmSmart/DirectLoginCallback/index.js
  4. +0
    -72
      src/pages/iAmSmart/FallCallback/index.js
  5. +2
    -2
      src/routes/LoginRoutes.js
  6. +1
    -0
      src/utils/ApiPathConst.js

+ 9
- 12
src/pages/authentication/RegisterCustom.js View File

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


+ 21
- 4
src/pages/authentication/auth-forms/AuthLoginCustom.js View File

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

}




+ 1
- 1
src/pages/iAmSmart/DirectLoginCallback/index.js View File

@@ -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")
},


+ 0
- 72
src/pages/iAmSmart/FallCallback/index.js View File

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

+ 2
- 2
src/routes/LoginRoutes.js View File

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


+ 1
- 0
src/utils/ApiPathConst.js View File

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


Loading…
Cancel
Save