From 50d157a1daf3dabff4d4bd77ffb944f8d686fdd7 Mon Sep 17 00:00:00 2001 From: OxSaitama Date: Wed, 5 Apr 2023 13:23:17 +0200 Subject: [PATCH] add login page --- src/front/Api/BaseApiService.ts | 7 ++++--- .../Api/LeCoffreApi/Notary/Users/Users.ts | 13 +++++++++++++ .../Layouts/Login/classes.module.scss | 2 ++ src/front/Components/Layouts/Login/index.tsx | 19 +++++++++++++++++++ src/front/Config/VariablesFront.ts | 6 ------ src/front/Stores/BaseStore.ts | 1 - src/pages/login.tsx | 5 +++++ 7 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 src/front/Components/Layouts/Login/classes.module.scss create mode 100644 src/front/Components/Layouts/Login/index.tsx create mode 100644 src/pages/login.tsx diff --git a/src/front/Api/BaseApiService.ts b/src/front/Api/BaseApiService.ts index a1803bf1..963ceebf 100644 --- a/src/front/Api/BaseApiService.ts +++ b/src/front/Api/BaseApiService.ts @@ -12,7 +12,6 @@ export default abstract class BaseApiService { process.env["NEXT_PUBLIC_RPC_GATEWAY_PORT"] + process.env["NEXT_PUBLIC_RPC_GATEWAY_ROOT_URL"]; - // eslint-disable-next-line @typescript-eslint/no-empty-function protected constructor() {} protected buildHeaders(contentType: ContentType) { @@ -21,6 +20,8 @@ export default abstract class BaseApiService { if (contentType === ContentType.JSON) { headers.set("Content-Type", contentType); } + headers.set("Access-Control-Allow-Origin", "*"); + return headers; } @@ -34,7 +35,7 @@ export default abstract class BaseApiService { method: "GET", headers: this.buildHeaders(ContentType.JSON), }); - + console.log(request); return this.sendRequest(request); } @@ -95,11 +96,11 @@ export default abstract class BaseApiService { private async sendRequest(request: () => Promise): Promise { const response = await request(); + response.headers.set("Access-Control-Allow-Origin", "*"); return this.processResponse(response, request); } protected async processResponse(response: Response, request: () => Promise): Promise { - // eslint-disable-next-line @typescript-eslint/no-explicit-any let responseJson: any | null; try { responseJson = await response.json(); diff --git a/src/front/Api/LeCoffreApi/Notary/Users/Users.ts b/src/front/Api/LeCoffreApi/Notary/Users/Users.ts index da7776fe..bbc5ffa7 100644 --- a/src/front/Api/LeCoffreApi/Notary/Users/Users.ts +++ b/src/front/Api/LeCoffreApi/Notary/Users/Users.ts @@ -29,6 +29,19 @@ export default class Users extends BaseNotary { } } + public async getAuthorizationCode(): Promise { + try { + await this.getRequest(new URL(`https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1? + client_id=4501646203F3EF67 + &redirect_uri=http://locahost:3000 + &scope=openid,profile,offline_access + &response_type=code`)); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } + public async getOne(uid: string): Promise { const url = new URL(this.baseURl.concat("/").concat(uid)); try { diff --git a/src/front/Components/Layouts/Login/classes.module.scss b/src/front/Components/Layouts/Login/classes.module.scss new file mode 100644 index 00000000..c3a2af63 --- /dev/null +++ b/src/front/Components/Layouts/Login/classes.module.scss @@ -0,0 +1,2 @@ +.root { +} diff --git a/src/front/Components/Layouts/Login/index.tsx b/src/front/Components/Layouts/Login/index.tsx new file mode 100644 index 00000000..d4d3c70f --- /dev/null +++ b/src/front/Components/Layouts/Login/index.tsx @@ -0,0 +1,19 @@ +import Users from "@Front/Api/LeCoffreApi/Notary/Users/Users"; +import Button from "@Front/Components/DesignSystem/Button"; +import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography"; +import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate"; +import BasePage from "../Base"; +import classes from "./classes.module.scss"; + +export default class Login extends BasePage { + public override render(): JSX.Element { + return ( + +
+ login + +
+
+ ); + } +} diff --git a/src/front/Config/VariablesFront.ts b/src/front/Config/VariablesFront.ts index b0b79ffc..fbbe7e55 100644 --- a/src/front/Config/VariablesFront.ts +++ b/src/front/Config/VariablesFront.ts @@ -12,10 +12,6 @@ export class FrontendVariables { public readonly NEXT_PUBLIC_API_URL!: string; - public readonly NEXT_PUBLIC_RPC_GATEWAY_MAINNET_URL!: string; - - public readonly NEXT_PUBLIC_RPC_GATEWAY_TESTNET_URL!: string; - public readonly NODE_ENV!: string; constructor() { @@ -24,8 +20,6 @@ export class FrontendVariables { this.WEB_PORT = process.env["WEB_PORT"]!; this.WEB_ROOT_URL = process.env["WEB_ROOT_URL"]!; this.NEXT_PUBLIC_API_URL = process.env["NEXT_PUBLIC_API_URL"]!; - this.NEXT_PUBLIC_RPC_GATEWAY_MAINNET_URL = process.env["NEXT_PUBLIC_RPC_GATEWAY_MAINNET_URL"]!; - this.NEXT_PUBLIC_RPC_GATEWAY_TESTNET_URL = process.env["NEXT_PUBLIC_RPC_GATEWAY_TESTNET_URL"]!; } public static getInstance(): FrontendVariables { diff --git a/src/front/Stores/BaseStore.ts b/src/front/Stores/BaseStore.ts index a8e77340..df448495 100644 --- a/src/front/Stores/BaseStore.ts +++ b/src/front/Stores/BaseStore.ts @@ -3,7 +3,6 @@ import EventEmitter from "@Front/Services/EventEmitter"; export default abstract class BaseStore { protected readonly event = new EventEmitter(); - // eslint-disable-next-line @typescript-eslint/no-empty-function protected constructor() {} public onChange(callback: (params: T) => void) { diff --git a/src/pages/login.tsx b/src/pages/login.tsx new file mode 100644 index 00000000..40f96abe --- /dev/null +++ b/src/pages/login.tsx @@ -0,0 +1,5 @@ +import Login from "@Front/Components/Layouts/Login"; + +export default function Route() { + return ; +}