diff --git a/next.config.js b/next.config.js index c2558b15..2d34b246 100644 --- a/next.config.js +++ b/next.config.js @@ -22,6 +22,7 @@ const nextConfig = { NEXT_PUBLIC_HOTJAR_VERSION: process.env.NEXT_PUBLIC_HOTJAR_VERSION, NEXT_PUBLIC_4NK_URL: process.env.NEXT_PUBLIC_4NK_URL, NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL, + NEXT_PUBLICK_ANK_BASE_REDIRECT_URI: process.env.NEXT_PUBLIC_ANK_BASE_REDIRECT_URI, NEXT_PUBLIC_DEFAULT_VALIDATOR_ID: process.env.NEXT_PUBLIC_DEFAULT_VALIDATOR_ID, NEXT_PUBLIC_DEFAULT_STORAGE_URLS: process.env.NEXT_PUBLIC_DEFAULT_STORAGE_URLS, }, @@ -42,6 +43,7 @@ const nextConfig = { NEXT_PUBLIC_HOTJAR_VERSION: process.env.NEXT_PUBLIC_HOTJAR_VERSION, NEXT_PUBLIC_4NK_URL: process.env.NEXT_PUBLIC_4NK_URL, NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL, + NEXT_PUBLICK_ANK_BASE_REDIRECT_URI: process.env.NEXT_PUBLIC_ANK_BASE_REDIRECT_URI, NEXT_PUBLIC_DEFAULT_VALIDATOR_ID: process.env.NEXT_PUBLIC_DEFAULT_VALIDATOR_ID, NEXT_PUBLIC_DEFAULT_STORAGE_URLS: process.env.NEXT_PUBLIC_DEFAULT_STORAGE_URLS, }, @@ -62,6 +64,7 @@ const nextConfig = { NEXT_PUBLIC_HOTJAR_VERSION: process.env.NEXT_PUBLIC_HOTJAR_VERSION, NEXT_PUBLIC_4NK_URL: process.env.NEXT_PUBLIC_4NK_URL, NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL, + NEXT_PUBLICK_ANK_BASE_REDIRECT_URI: process.env.NEXT_PUBLIC_ANK_BASE_REDIRECT_URI, NEXT_PUBLIC_DEFAULT_VALIDATOR_ID: process.env.NEXT_PUBLIC_DEFAULT_VALIDATOR_ID, NEXT_PUBLIC_DEFAULT_STORAGE_URLS: process.env.NEXT_PUBLIC_DEFAULT_STORAGE_URLS, }, diff --git a/src/front/Api/Auth/IdNot/index.ts b/src/front/Api/Auth/IdNot/index.ts index a4c3ae7b..782a2c81 100644 --- a/src/front/Api/Auth/IdNot/index.ts +++ b/src/front/Api/Auth/IdNot/index.ts @@ -41,12 +41,8 @@ export default class Auth extends BaseApiService { } public async idNotAuth(autorizationCode: string | string[]): Promise<{ idNotUser: any; authToken: string }> { - // const variables = FrontendVariables.getInstance(); - - // TODO: review - const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST; - - const url = new URL(`${baseBackUrl}/api/v1/idnot/auth/${autorizationCode}`); + const variables = FrontendVariables.getInstance(); + const url = new URL(`${variables.BACK_API_PROTOCOL}://${variables.BACK_API_HOST}:${variables.BACK_API_PORT}/api/v1/idnot/auth/${autorizationCode}`); try { return await this.postRequest<{ idNotUser: any; authToken: string }>(url); } catch (err) { @@ -56,9 +52,8 @@ export default class Auth extends BaseApiService { } public async getIdNotUser(): Promise<{ success: boolean; data: any }> { - const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST; - - const url = new URL(`${baseBackUrl}/api/v1/idnot/user`); + const variables = FrontendVariables.getInstance(); + const url = new URL(`${variables.BACK_API_PROTOCOL}://${variables.BACK_API_HOST}:${variables.BACK_API_PORT}/api/v1/idnot/user`); try { return await this.getRequest(url); } @@ -69,9 +64,8 @@ export default class Auth extends BaseApiService { } public async getIdNotOfficeForUser(userId: string): Promise { - const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST; - - const url = new URL(`${baseBackUrl}/api/v1/idnot/user/rattachements`); + const variables = FrontendVariables.getInstance(); + const url = new URL(`${variables.BACK_API_PROTOCOL}://${variables.BACK_API_HOST}:${variables.BACK_API_PORT}/api/v1/idnot/user/rattachements`); url.searchParams.set('idNot', userId); try { return await this.getRequest(url); @@ -83,9 +77,8 @@ export default class Auth extends BaseApiService { } public async getIdNotUserForOffice(officeId: string): Promise { - const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST; - - const url = new URL(`${baseBackUrl}/api/v1/idnot/office/rattachements`); + const variables = FrontendVariables.getInstance(); + const url = new URL(`${variables.BACK_API_PROTOCOL}://${variables.BACK_API_HOST}:${variables.BACK_API_PORT}/api/v1/idnot/office/rattachements`); url.searchParams.set('idNot', officeId); try { return await this.getRequest(url); @@ -96,9 +89,8 @@ export default class Auth extends BaseApiService { } public async getUserProcessByIdNot(pairingId: string): Promise<{ success: boolean; data: { processId: string, processData: { [key: string]: any } } }> { - const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST; - - const url = new URL(`${baseBackUrl}/api/v1/process/user`); + const variables = FrontendVariables.getInstance(); + const url = new URL(`${variables.BACK_API_PROTOCOL}://${variables.BACK_API_HOST}:${variables.BACK_API_PORT}/api/v1/process/user`); url.searchParams.set('pairingId', pairingId); try { return await this.getRequest(url); @@ -109,9 +101,8 @@ export default class Auth extends BaseApiService { } public async getOfficeProcessByIdNot(): Promise<{ success: boolean; data: { processId: string, processData: { [key: string]: any } } }> { - const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST; - - const url = new URL(`${baseBackUrl}/api/v1/process/office`); + const variables = FrontendVariables.getInstance(); + const url = new URL(`${variables.BACK_API_PROTOCOL}://${variables.BACK_API_HOST}:${variables.BACK_API_PORT}/api/v1/process/office`); try { return await this.getRequest(url); } catch (err) { diff --git a/src/front/Api/LeCoffreApi/Notary/Customers/Customers.ts b/src/front/Api/LeCoffreApi/Notary/Customers/Customers.ts index a36c547b..e02781d2 100644 --- a/src/front/Api/LeCoffreApi/Notary/Customers/Customers.ts +++ b/src/front/Api/LeCoffreApi/Notary/Customers/Customers.ts @@ -89,10 +89,7 @@ export default class Customers extends BaseNotary { } public async sendReminder(office: any, customer: any): Promise { - // TODO: review - const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST; - - const url = new URL(`${baseBackUrl}/api/send_reminder`); + const url = new URL(`${this.variables.BACK_API_PROTOCOL}://${this.variables.BACK_API_HOST}:${this.variables.BACK_API_PORT}/api/send_reminder`); //const url = new URL(this.baseURl.concat(`/${uid}/send_reminder`)); try { diff --git a/src/front/Components/Layouts/Login/StepEmail/index.tsx b/src/front/Components/Layouts/Login/StepEmail/index.tsx index f9b904ee..4245f460 100644 --- a/src/front/Components/Layouts/Login/StepEmail/index.tsx +++ b/src/front/Components/Layouts/Login/StepEmail/index.tsx @@ -41,18 +41,18 @@ export default function StepEmail(props: IProps) { const router = useRouter(); const error = router.query["error"]; + const variables = FrontendVariables.getInstance(); + const redirectUserOnConnection = useCallback(() => { /* TODO: review - const variables = FrontendVariables.getInstance(); router.push( `${variables.IDNOT_BASE_URL + variables.IDNOT_AUTHORIZE_ENDPOINT}?client_id=${variables.IDNOT_CLIENT_ID}&redirect_uri=${ variables.FRONT_APP_HOST }/authorized-client&scope=openid,profile&response_type=code`, ); */ - const redirectUri = 'http://local.4nkweb.com:3000/authorized-client'; router.push( - `https://qual-connexion.idnot.fr/user/IdPOAuth2/authorize/idnot_idp_v1?client_id=B3CE56353EDB15A9&redirect_uri=${redirectUri}&scope=openid,profile&response_type=code`, + `${variables.IDNOT_BASE_URL}/user/${variables.IDNOT_AUTHORIZE_ENDPOINT}?client_id=${variables.IDNOT_CLIENT_ID}&redirect_uri=${variables.ANK_BASE_REDIRECT_URI}&scope=openid,profile&response_type=code`, ); }, [router]); @@ -66,7 +66,7 @@ export default function StepEmail(props: IProps) { const closeNoEmailModal = useCallback(() => { setIsErrorModalOpen(0); - router.push("https://connexion.idnot.fr/"); + router.push(variables.IDNOT_BASE_URL); }, [router]); // const closeContactAdminModal = () => { diff --git a/src/front/Config/VariablesFront.ts b/src/front/Config/VariablesFront.ts index 8c5e7b49..dcf83593 100644 --- a/src/front/Config/VariablesFront.ts +++ b/src/front/Config/VariablesFront.ts @@ -35,6 +35,8 @@ export class FrontendVariables { public API_URL!: string; + public ANK_BASE_REDIRECT_URI!: string; + private constructor() {} public static getInstance(): FrontendVariables {