diff --git a/.env.example b/.env.example index 17ef3e5a..c94afc0a 100644 --- a/.env.example +++ b/.env.example @@ -5,7 +5,7 @@ NODE_ENV=production # Configuration IDNOT IDNOT_ANNUARY_BASE_URL=https://qual-api.notaires.fr/annuaire # IDNOT_REDIRECT_URI=http://local.4nkweb.com:3004/authorized-client -IDNOT_REDIRECT_URI=https://dev4.4nkweb.com/lecoffre/authorized-client +IDNOT_REDIRECT_URI=http://local.lecoffreio.4nkweb:3000/authorized-client IDNOT_TOKEN_URL=https://qual-connexion.idnot.fr/user/IdPOAuth2/token/idnot_idp_v1 IDNOT_API_BASE_URL=https://qual-api.notaires.fr/annuaire diff --git a/src/front/Api/Auth/IdNot/index.ts b/src/front/Api/Auth/IdNot/index.ts index 3c96a210..a89fe015 100644 --- a/src/front/Api/Auth/IdNot/index.ts +++ b/src/front/Api/Auth/IdNot/index.ts @@ -27,7 +27,11 @@ export default class Auth extends BaseApiService { public async loginWithIdNot() { const variables = FrontendVariables.getInstance(); - const redirectUri = variables.IDNOT_REDIRECT_URI || `${variables.FRONT_APP_HOST}/authorized-client`; + let redirectUri = variables.IDNOT_REDIRECT_URI || ""; + if (!redirectUri) { + console.warn("[IDNOT] NEXT_PUBLIC_IDNOT_REDIRECT_URI vide; fallback sur FRONT_APP_HOST/authorized-client"); + redirectUri = `${variables.FRONT_APP_HOST}/authorized-client`; + } const url = new URL( `${variables.IDNOT_BASE_URL + variables.IDNOT_AUTHORIZE_ENDPOINT}?client_id=${variables.IDNOT_CLIENT_ID}&redirect_uri=${redirectUri}&scope=openid,profile&response_type=code`, ); diff --git a/src/front/Components/Layouts/Login/StepEmail/index.tsx b/src/front/Components/Layouts/Login/StepEmail/index.tsx index 75216c72..1598e87b 100644 --- a/src/front/Components/Layouts/Login/StepEmail/index.tsx +++ b/src/front/Components/Layouts/Login/StepEmail/index.tsx @@ -43,7 +43,11 @@ export default function StepEmail(props: IProps) { const error = router.query["error"]; const redirectUserOnConnection = useCallback(() => { const variables = FrontendVariables.getInstance(); - const redirectUri = variables.IDNOT_REDIRECT_URI || `${variables.FRONT_APP_HOST}/authorized-client`; + let redirectUri = variables.IDNOT_REDIRECT_URI || ""; + if (!redirectUri) { + console.warn("[IDNOT] NEXT_PUBLIC_IDNOT_REDIRECT_URI vide; fallback sur FRONT_APP_HOST/authorized-client"); + redirectUri = `${variables.FRONT_APP_HOST}/authorized-client`; + } const authorizeBase = `${variables.IDNOT_BASE_URL}${variables.IDNOT_AUTHORIZE_ENDPOINT}`; router.push( `${authorizeBase}?client_id=${variables.IDNOT_CLIENT_ID}&redirect_uri=${encodeURIComponent(redirectUri)}&scope=openid,profile&response_type=code`,