add new variables for Idnot connexion
This commit is contained in:
parent
05ac4a9542
commit
b9e4483a9e
@ -11,6 +11,8 @@ const nextConfig = {
|
|||||||
BACK_API_VERSION: process.env.BACK_API_VERSION,
|
BACK_API_VERSION: process.env.BACK_API_VERSION,
|
||||||
FRONT_APP_HOST: process.env.FRONT_APP_HOST,
|
FRONT_APP_HOST: process.env.FRONT_APP_HOST,
|
||||||
FRONT_APP_PORT: process.env.FRONT_APP_PORT,
|
FRONT_APP_PORT: process.env.FRONT_APP_PORT,
|
||||||
|
IDNOT_AUTHORIZE_ENDPOINT: process.env.IDNOT_AUTHORIZE_ENDPOINT,
|
||||||
|
IDNOT_CLIENT_ID: process.env.IDNOT_CLIENT_ID,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,28 +11,16 @@ export default class Auth extends BaseApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static getInstance(): Auth {
|
public static getInstance(): Auth {
|
||||||
return (this.instance = this.instance ?? new Auth());
|
return (this.instance = this.instance ?? new this());
|
||||||
}
|
|
||||||
|
|
||||||
public async userSignin() {
|
|
||||||
const url = new URL(
|
|
||||||
"https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1?client_id=4501646203F3EF67&redirect_uri=http://0.0.0.0:3000/authorized-client&scope=openid,profile,offline_access&response_type=code"
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
return await this.getRequest<any>(url);
|
|
||||||
} catch (err) {
|
|
||||||
this.onError(err);
|
|
||||||
return Promise.reject(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getIdnotJwt(autorizationCode: string | string[]): Promise<any> {
|
public async getIdnotJwt(autorizationCode: string | string[]): Promise<any> {
|
||||||
const baseBackUrl = FrontendVariables.getInstance().BACK_API_PROTOCOL +
|
const variables = FrontendVariables.getInstance();
|
||||||
FrontendVariables.getInstance().BACK_API_HOST +
|
const baseBackUrl =
|
||||||
(FrontendVariables.getInstance().BACK_API_PORT ? ":" + FrontendVariables.getInstance().BACK_API_PORT : "");
|
variables.BACK_API_PROTOCOL +
|
||||||
const url = new URL(
|
variables.BACK_API_HOST +
|
||||||
`${baseBackUrl}/api/v1/idnot-user/${autorizationCode}`
|
(variables.BACK_API_PORT ? ":" + variables.BACK_API_PORT : "");
|
||||||
);
|
const url = new URL(`${baseBackUrl}/api/v1/idnot-user/${autorizationCode}`);
|
||||||
try {
|
try {
|
||||||
return await this.postRequest<any>(url);
|
return await this.postRequest<any>(url);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -3,34 +3,47 @@ import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography";
|
|||||||
import BasePage from "../Base";
|
import BasePage from "../Base";
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import CoffreIcon from "@Assets/Icons/coffre.svg";
|
import CoffreIcon from "@Assets/Icons/coffre.svg";
|
||||||
import LandingImage from "./landing-connect.png"
|
import LandingImage from "./landing-connect.png";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
||||||
import { FrontendVariables } from "@Front/Config/VariablesFront";
|
import { FrontendVariables } from "@Front/Config/VariablesFront";
|
||||||
|
|
||||||
export default class LoginClass extends BasePage {
|
export default class LoginClass extends BasePage {
|
||||||
public override render(): JSX.Element {
|
public override render(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<DefaultDoubleSidePage title={"Login"} image={LandingImage}>
|
<DefaultDoubleSidePage title={"Login"} image={LandingImage}>
|
||||||
<div className={classes["root"]}>
|
<div className={classes["root"]}>
|
||||||
<Image alt="coffre" src={CoffreIcon} />
|
<Image alt="coffre" src={CoffreIcon} />
|
||||||
<Typography typo={ITypo.H1}><div className={classes["title"]}>Connexion espace professionnel</div></Typography>
|
<Typography typo={ITypo.H1}>
|
||||||
<Button onClick={this.redirectUserOnConnection}>S’identifier avec ID.not</Button>
|
<div className={classes["title"]}>
|
||||||
<Typography typo={ITypo.P_18}><div className={classes["forget-password"]}>Vous n’arrivez pas à vous connecter ?</div></Typography>
|
Connexion espace professionnel
|
||||||
<Button variant={EButtonVariant.LINE} >Contacter l’administrateur</Button>
|
</div>
|
||||||
</div>
|
</Typography>
|
||||||
</DefaultDoubleSidePage>
|
<Button onClick={this.redirectUserOnConnection}>
|
||||||
);
|
S’identifier avec ID.not
|
||||||
}
|
</Button>
|
||||||
|
<Typography typo={ITypo.P_18}>
|
||||||
|
<div className={classes["forget-password"]}>
|
||||||
|
Vous n’arrivez pas à vous connecter ?
|
||||||
|
</div>
|
||||||
|
</Typography>
|
||||||
|
<Button variant={EButtonVariant.LINE}>
|
||||||
|
Contacter l’administrateur
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</DefaultDoubleSidePage>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private redirectUserOnConnection() {
|
private redirectUserOnConnection() {
|
||||||
// check variable
|
const variables = FrontendVariables.getInstance();
|
||||||
const baseFronturl = FrontendVariables.getInstance().BACK_API_PROTOCOL +
|
const baseFronturl =
|
||||||
FrontendVariables.getInstance().FRONT_APP_HOST +
|
variables.BACK_API_PROTOCOL +
|
||||||
(FrontendVariables.getInstance().FRONT_APP_PORT ? ":" + FrontendVariables.getInstance().FRONT_APP_PORT : "");
|
variables.FRONT_APP_HOST +
|
||||||
|
(variables.FRONT_APP_PORT ? ":" + variables.FRONT_APP_PORT : "");
|
||||||
const url = `https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1?client_id=4501646203F3EF67&redirect_uri=${baseFronturl}/authorized-client&scope=openid,profile,offline_access&response_type=code`
|
const authorizeEndPoint = variables.IDNOT_AUTHORIZE_ENDPOINT;
|
||||||
|
const clientId = variables.IDNOT_CLIENT_ID;
|
||||||
window.location.assign(url)
|
const url = `${authorizeEndPoint}?client_id=${clientId}&redirect_uri=${baseFronturl}/authorized-client&scope=openid,profile,offline_access&response_type=code`;
|
||||||
}
|
window.location.assign(url);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -81,7 +81,6 @@ export default function LoginCallBack(props: IPropsClass) {
|
|||||||
await authService.getIdnotJwt(code);
|
await authService.getIdnotJwt(code);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
// Router.push('/login');
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
getIdNotJwt();
|
getIdNotJwt();
|
||||||
|
@ -15,6 +15,10 @@ export class FrontendVariables {
|
|||||||
|
|
||||||
public FRONT_APP_PORT!: string;
|
public FRONT_APP_PORT!: string;
|
||||||
|
|
||||||
|
public IDNOT_AUTHORIZE_ENDPOINT!: string;
|
||||||
|
|
||||||
|
public IDNOT_CLIENT_ID!: string;
|
||||||
|
|
||||||
private constructor() {}
|
private constructor() {}
|
||||||
|
|
||||||
public static getInstance(): FrontendVariables {
|
public static getInstance(): FrontendVariables {
|
||||||
|
@ -19,9 +19,11 @@ type AppPropsWithLayout = AppProps & {
|
|||||||
backApiVersion: string,
|
backApiVersion: string,
|
||||||
frontAppHost: string,
|
frontAppHost: string,
|
||||||
frontAppPort: string,
|
frontAppPort: string,
|
||||||
|
idNotAuthorizeEndpoint: string;
|
||||||
|
idNotClientId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const MyApp = (({ Component, pageProps, backApiProtocol, backApiHost, backApiPort, backApiRootUrl, backApiVersion, frontAppHost, frontAppPort }: AppPropsWithLayout) => {
|
const MyApp = (({ Component, pageProps, backApiProtocol, backApiHost, backApiPort, backApiRootUrl, backApiVersion, frontAppHost, frontAppPort, idNotAuthorizeEndpoint, idNotClientId }: AppPropsWithLayout) => {
|
||||||
const getLayout = Component.getLayout ?? ((page) => <DefaultLayout children={page}></DefaultLayout>);
|
const getLayout = Component.getLayout ?? ((page) => <DefaultLayout children={page}></DefaultLayout>);
|
||||||
|
|
||||||
FrontendVariables.getInstance().BACK_API_PROTOCOL = backApiProtocol;
|
FrontendVariables.getInstance().BACK_API_PROTOCOL = backApiProtocol;
|
||||||
@ -31,6 +33,9 @@ const MyApp = (({ Component, pageProps, backApiProtocol, backApiHost, backApiPor
|
|||||||
FrontendVariables.getInstance().BACK_API_VERSION = backApiVersion;
|
FrontendVariables.getInstance().BACK_API_VERSION = backApiVersion;
|
||||||
FrontendVariables.getInstance().FRONT_APP_HOST = frontAppHost;
|
FrontendVariables.getInstance().FRONT_APP_HOST = frontAppHost;
|
||||||
FrontendVariables.getInstance().FRONT_APP_PORT = frontAppPort;
|
FrontendVariables.getInstance().FRONT_APP_PORT = frontAppPort;
|
||||||
|
FrontendVariables.getInstance().IDNOT_AUTHORIZE_ENDPOINT = idNotAuthorizeEndpoint;
|
||||||
|
FrontendVariables.getInstance().IDNOT_CLIENT_ID = idNotClientId;
|
||||||
|
|
||||||
|
|
||||||
return getLayout(<Component {...pageProps} />);
|
return getLayout(<Component {...pageProps} />);
|
||||||
}) as AppType;
|
}) as AppType;
|
||||||
@ -44,6 +49,8 @@ MyApp.getInitialProps = async () => {
|
|||||||
backApiVersion: process.env["BACK_API_VERSION"],
|
backApiVersion: process.env["BACK_API_VERSION"],
|
||||||
frontAppHost: process.env["FRONT_APP_HOST"],
|
frontAppHost: process.env["FRONT_APP_HOST"],
|
||||||
frontAppPort: process.env["FRONT_APP_PORT"],
|
frontAppPort: process.env["FRONT_APP_PORT"],
|
||||||
|
idNotAuthorizeEndpoint: process.env["IDNOT_AUTHORIZE_ENDPOINT"],
|
||||||
|
idNotClientId: process.env["IDNOT_CLIENT_ID"],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user