diff --git a/package.json b/package.json index 8f6f84e7..0ad651d1 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@types/react-dom": "18.0.11", "class-validator": "^0.14.0", "classnames": "^2.3.2", + "crypto-random-string": "^5.0.0", "dotenv": "^16.0.3", "eslint": "8.36.0", "eslint-config-next": "13.2.4", diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts index b03e1c45..8ce85c2d 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts @@ -57,6 +57,11 @@ export default class Files extends BaseSuperAdmin { } } + public getUploadLink(uid: string): string { + return this.baseURl.concat(`/upload/${uid}`); + } + + public async getByUid(uid: string, q?: any): Promise { const url = new URL(this.baseURl.concat(`/${uid}`)); const query = { q }; diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index c8a51fb9..9db8c4fd 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -20,6 +20,7 @@ import React from "react"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; import OcrResult from "./OcrResult"; +import Files from "@Front/Api/LeCoffreApi/SuperAdmin/Files/Files"; type IProps = {}; @@ -90,7 +91,7 @@ class ViewDocumentsClass extends BasePage { )}
- +
{this.state.document.files.length > 1 && (
{ private downloadFile() { const fileName = this.state.selectedFile?.file_path?.split("/").pop(); - fetch(this.state.selectedFile?.file_path as string) + fetch(Files.getInstance().getUploadLink(this.state.selectedFile?.uid as string)) .then((resp) => resp.blob()) .then((blob) => { const url = window.URL.createObjectURL(blob); diff --git a/src/front/Components/Layouts/LoginCallback/index.tsx b/src/front/Components/Layouts/LoginCallback/index.tsx index a794066e..67732034 100644 --- a/src/front/Components/Layouts/LoginCallback/index.tsx +++ b/src/front/Components/Layouts/LoginCallback/index.tsx @@ -10,7 +10,7 @@ import { useRouter } from "next/router"; //import React, { useEffect, useState } from "react"; import React from "react"; //import Loader from "@Front/Components/DesignSystem/Loader"; -import Auth from "@Front/Api/Auth/IdNot"; +//import Auth from "@Front/Api/Auth/IdNot"; import Folder from "../Folder"; import LoginClass from "../Login"; @@ -75,15 +75,15 @@ export default function LoginCallBack(props: IPropsClass) { const router = useRouter(); const { code } = router.query; if (code) { - const getIdNotJwt = async () => { - try { - const authService = Auth.getInstance(); - await authService.getIdnotJwt(code); - } catch (error) { - console.error(error); - } - }; - getIdNotJwt(); + // const getIdNotJwt = async () => { + // try { + // const authService = Auth.getInstance(); + // await authService.getIdnotJwt(code); + // } catch (error) { + // console.error(error); + // } + // }; + //getIdNotJwt(); return ; } return ; diff --git a/src/front/Components/Layouts/LoginCustomer/index.tsx b/src/front/Components/Layouts/LoginCustomer/index.tsx index ded0c9a6..fe5938c8 100644 --- a/src/front/Components/Layouts/LoginCustomer/index.tsx +++ b/src/front/Components/Layouts/LoginCustomer/index.tsx @@ -6,6 +6,8 @@ import Image from "next/image"; import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage"; import FranceConnectIcon from "./france-connect.svg"; import ExportIcon from "@Assets/Icons/export.svg"; +import { FrontendVariables } from "@Front/Config/VariablesFront"; +import cryptoRandomString from "crypto-random-string"; export default class LoginCustomer extends BasePage { public override render(): JSX.Element { @@ -35,12 +37,12 @@ export default class LoginCustomer extends BasePage { } private redirectUserOnConnection() { - // const variables = FrontendVariables.getInstance(); + const variables = FrontendVariables.getInstance(); // const baseFronturl = // variables.BACK_API_PROTOCOL + variables.FRONT_APP_HOST + (variables.FRONT_APP_PORT ? ":" + variables.FRONT_APP_PORT : ""); - // const authorizeEndPoint = variables.IDNOT_AUTHORIZE_ENDPOINT; - // const clientId = variables.IDNOT_CLIENT_ID; - // const url = `${authorizeEndPoint}?client_id=${clientId}&redirect_uri=${baseFronturl}/authorized-client&scope=openid,profile,offline_access&response_type=code`; - // window.location.assign(url); + const authorizeEndPoint = variables.FC_AUTHORIZE_ENDPOINT; + const clientId = variables.FC_CLIENT_ID; + const url = `${authorizeEndPoint}?client_id=${clientId}&redirect_uri=http://localhost:8080/login-callback&scope=openid&response_type=code&state=${cryptoRandomString({length: 64})}&nonce=${cryptoRandomString({length: 64})}&acr_values=eidas1`; + window.location.assign(url); } } diff --git a/src/front/Config/VariablesFront.ts b/src/front/Config/VariablesFront.ts index 20422e9b..76f85149 100644 --- a/src/front/Config/VariablesFront.ts +++ b/src/front/Config/VariablesFront.ts @@ -17,6 +17,10 @@ export class FrontendVariables { public KEY_DATA!: string; + public FC_AUTHORIZE_ENDPOINT!: string; + + public FC_CLIENT_ID!: string; + private constructor() {} public static getInstance(): FrontendVariables { diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 60837af0..aea120fc 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -19,6 +19,8 @@ type AppPropsWithLayout = AppProps & { frontAppHost: string; idNotAuthorizeEndpoint: string; idNotClientId: string; + fcAuthorizeEndpoint: string; + fcClientId: string; }; const MyApp = (({ @@ -31,6 +33,8 @@ const MyApp = (({ frontAppHost, idNotAuthorizeEndpoint, idNotClientId, + fcAuthorizeEndpoint, + fcClientId }: AppPropsWithLayout) => { const getLayout = Component.getLayout ?? ((page) => ); @@ -42,6 +46,8 @@ const MyApp = (({ instance.FRONT_APP_HOST = frontAppHost; instance.IDNOT_AUTHORIZE_ENDPOINT = idNotAuthorizeEndpoint; instance.IDNOT_CLIENT_ID = idNotClientId; + instance.FC_AUTHORIZE_ENDPOINT= fcAuthorizeEndpoint; + instance.FC_CLIENT_ID = fcClientId return getLayout(); }) as AppType; @@ -56,6 +62,8 @@ MyApp.getInitialProps = async () => { frontAppPort: process.env["NEXT_PUBLIC_FRONT_APP_PORT"], idNotAuthorizeEndpoint: process.env["NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT"], idNotClientId: process.env["NEXT_PUBLIC_IDNOT_CLIENT_ID"], + fcAuthorizeEndpoint: process.env["NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT"], + fcClientId: process.env["NEXT_PUBLIC_FC_CLIENT_ID"] }; }; diff --git a/src/pages/login-callback.tsx b/src/pages/login-callback.tsx new file mode 100644 index 00000000..eb839556 --- /dev/null +++ b/src/pages/login-callback.tsx @@ -0,0 +1,5 @@ +import ClientDashboard from "@Front/Components/Layouts/ClientDashboard"; + +export default function Route() { + return ; +}