diff --git a/src/app/api/franceConnect/CustomerController.ts b/src/app/api/franceConnect/CustomerController.ts deleted file mode 100644 index 7d05215f..00000000 --- a/src/app/api/franceConnect/CustomerController.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { Response, Request } from "express"; -import { Controller, Post } from "@ControllerPattern/index"; -import ApiController from "@Common/system/controller-pattern/ApiController"; -import { Service } from "typedi"; -import AuthService, { ICustomerJwtPayload } from "@Services/common/AuthService/AuthService"; -import { JwtPayload } from "jsonwebtoken"; - -@Controller() -@Service() -export default class CustomerController extends ApiController { - constructor(private authService: AuthService) { - super(); - } - - // @Post("/api/v1/france-connect/customer/login/:email") - // protected async login(req: Request, response: Response) { - // try { - // const email = req.params["email"]; - // if (!email) throw new Error("email is required"); - - // const payload = await this.authService.getCustomerJwtPayload(email); - // if (!payload) { - // this.httpNotFoundRequest(response); - // return; - // } - // const accessToken = this.authService.generateAccessToken(payload); - // const refreshToken = this.authService.generateRefreshToken(payload); - // //success - // this.httpSuccess(response, { accessToken, refreshToken }); - // } catch (error) { - // this.httpInternalError(response); - // return; - // } - // } - - @Post("/api/v1/france-connect/customer/refresh-token") - protected async refreshToken(req: Request, response: Response) { - try { - const authHeader = req.headers["authorization"]; - const token = authHeader && authHeader.split(" ")[1]; - - if (!token) { - this.httpBadRequest(response); - return; - } - - let accessToken; - this.authService.verifyRefreshToken(token, (err, customerPayload) => { - if (err) { - this.httpUnauthorized(response); - return; - } - - const customer = customerPayload as JwtPayload; - delete customer.iat; - delete customer!.exp; - accessToken = this.authService.generateAccessToken({...customer} as ICustomerJwtPayload); - }); - - //success - this.httpSuccess(response, {accessToken}); - } catch (error) { - this.httpInternalError(response); - return; - } - } -} diff --git a/src/app/api/id360/CustomerController.ts b/src/app/api/id360/CustomerController.ts index 1af0e969..086b40b0 100644 --- a/src/app/api/id360/CustomerController.ts +++ b/src/app/api/id360/CustomerController.ts @@ -34,11 +34,9 @@ export default class CustomerController extends ApiController { return; } try { + await new Promise( resolve => setTimeout(resolve, 3000)); // wait 3 seconds to be sure that the enrollment is finilazed const res = await this.id360Service.getEnrollment(callbackToken); const enrollment = await res.json() as EnrollmentResponse; - if(enrollment.status === "STARTED") { - this.loginCallback(req, response); - } if (enrollment.status !== "OK") { this.httpUnauthorized(response, "Enrollment status is not OK"); return; diff --git a/src/app/index.ts b/src/app/index.ts index 274b1ed2..f5c3f00a 100644 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -9,7 +9,6 @@ import DeedTypesControllerSuperAdmin from "./api/super-admin/DeedTypesController import DocumentsControllerSuperAdmin from "./api/super-admin/DocumentsController"; import DocumentTypesControllerSuperAdmin from "./api/super-admin/DocumentTypesController"; import IdNotUserController from "./api/idnot/UserController"; -import FranceConnectCustomerController from "./api/franceConnect/CustomerController"; import FilesControllerSuperAdmin from "./api/super-admin/FilesController"; import RulesControllerSuperAdmin from "./api/super-admin/RulesController"; import RolesControllerSuperAdmin from "./api/super-admin/RolesController"; @@ -64,7 +63,6 @@ export default { Container.get(DocumentTypesControllerSuperAdmin); Container.get(LiveVoteController); Container.get(IdNotUserController); - Container.get(FranceConnectCustomerController); Container.get(FilesControllerSuperAdmin); Container.get(DocumentsControllerSuperAdmin); Container.get(RulesControllerSuperAdmin); diff --git a/src/common/system/controller-pattern/BaseController.ts b/src/common/system/controller-pattern/BaseController.ts index 7baa9c02..b13d997a 100644 --- a/src/common/system/controller-pattern/BaseController.ts +++ b/src/common/system/controller-pattern/BaseController.ts @@ -45,6 +45,7 @@ export default abstract class BaseController { } protected httpResponse(response: Response, httpCode: HttpCodes, responseData: IResponseData = {}) { + console.log("httpResponse", httpCode, responseData); if (responseData instanceof Error) { throw responseData; }