From 553902e52a46adf4d3b6bc0367d1126c181d6752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?gr=C3=A9goire=20parant?= Date: Thu, 16 Sep 2021 17:57:14 +0200 Subject: [PATCH 1/2] Add log for Oauth login connexion (#1468) Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 10 ++++++---- pusher/src/Controller/AuthenticateController.ts | 11 ++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 0aba0379..7ad861dd 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -9,7 +9,7 @@ import { Room } from "./Room"; import { _ServiceWorker } from "../Network/ServiceWorker"; import { loginSceneVisibleIframeStore } from "../Stores/LoginSceneStore"; import { userIsConnected } from "../Stores/MenuStore"; -import {analyticsClient} from "../Administration/AnalyticsClient"; +import { analyticsClient } from "../Administration/AnalyticsClient"; class ConnectionManager { private localUser!: LocalUser; @@ -78,8 +78,10 @@ class ConnectionManager { this._currentRoom = null; if (connexionType === GameConnexionTypes.login) { this._currentRoom = await Room.createRoom(new URL(localUserStore.getLastRoomUrl())); - this.loadOpenIDScreen(); - return Promise.reject(new Error("You will be redirect on login page")); + if (this.loadOpenIDScreen() !== null) { + return Promise.reject(new Error("You will be redirect on login page")); + } + urlManager.pushRoomIdToUrl(this._currentRoom); } else if (connexionType === GameConnexionTypes.jwt) { const urlParams = new URLSearchParams(window.location.search); const code = urlParams.get("code"); @@ -188,7 +190,7 @@ class ConnectionManager { return Promise.reject(new Error("Invalid URL")); } if (this.localUser) { - analyticsClient.identifyUser(this.localUser.uuid) + analyticsClient.identifyUser(this.localUser.uuid); } this.serviceWorker = new _ServiceWorker(); diff --git a/pusher/src/Controller/AuthenticateController.ts b/pusher/src/Controller/AuthenticateController.ts index 6403a8f1..a5d92782 100644 --- a/pusher/src/Controller/AuthenticateController.ts +++ b/pusher/src/Controller/AuthenticateController.ts @@ -27,12 +27,12 @@ export class AuthenticateController extends BaseController { console.warn("/message request was aborted"); }); - const { nonce, state, playUri } = parse(req.getQuery()); - if (!state || !nonce) { - res.writeStatus("400 Unauthorized").end("missing state and nonce URL parameters"); - return; - } try { + const { nonce, state, playUri } = parse(req.getQuery()); + if (!state || !nonce) { + throw "missing state and nonce URL parameters"; + } + const loginUri = await openIDClient.authorizationUrl( state as string, nonce as string, @@ -42,6 +42,7 @@ export class AuthenticateController extends BaseController { res.writeHeader("Location", loginUri); return res.end(); } catch (e) { + console.error("openIDLogin => e", e); return this.errorToResponse(e, res); } }); From 8c96b514d4dfd8c1cfd40424c2cf08adf55a8399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?gr=C3=A9goire=20parant?= Date: Sat, 18 Sep 2021 11:35:29 +0200 Subject: [PATCH 2/2] HotFix to test hydra connexion (#1471) --- front/dist/.htaccess | 2 +- pusher/src/Controller/AuthenticateController.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/front/dist/.htaccess b/front/dist/.htaccess index 522fc2af..b3bdfa2d 100644 --- a/front/dist/.htaccess +++ b/front/dist/.htaccess @@ -23,4 +23,4 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule "^[_@]/" "/index.html" [L] RewriteRule "^register/" "/index.html" [L] RewriteRule "^login" "/index.html" [L] -RewriteRule "^jwt/" "/index.html" [L] +RewriteRule "^jwt" "/index.html" [L] diff --git a/pusher/src/Controller/AuthenticateController.ts b/pusher/src/Controller/AuthenticateController.ts index a5d92782..8f9cabf9 100644 --- a/pusher/src/Controller/AuthenticateController.ts +++ b/pusher/src/Controller/AuthenticateController.ts @@ -83,6 +83,7 @@ export class AuthenticateController extends BaseController { this.addCorsHeaders(res); return res.end(JSON.stringify({ authToken })); } catch (e) { + console.error("openIDCallback => ERROR", e); return this.errorToResponse(e, res); } }); @@ -153,6 +154,7 @@ export class AuthenticateController extends BaseController { }) ); } catch (e) { + console.error("register => ERROR", e); this.errorToResponse(e, res); } })(); @@ -214,6 +216,7 @@ export class AuthenticateController extends BaseController { } } } catch (error) { + console.error("profileCallback => ERROR", error); this.errorToResponse(error, res); } });