Add log for Oauth login connexion (#1468)

Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
This commit is contained in:
grégoire parant 2021-09-16 17:57:14 +02:00 committed by GitHub
parent 8d0f53ada0
commit 553902e52a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View File

@ -9,7 +9,7 @@ import { Room } from "./Room";
import { _ServiceWorker } from "../Network/ServiceWorker"; import { _ServiceWorker } from "../Network/ServiceWorker";
import { loginSceneVisibleIframeStore } from "../Stores/LoginSceneStore"; import { loginSceneVisibleIframeStore } from "../Stores/LoginSceneStore";
import { userIsConnected } from "../Stores/MenuStore"; import { userIsConnected } from "../Stores/MenuStore";
import {analyticsClient} from "../Administration/AnalyticsClient"; import { analyticsClient } from "../Administration/AnalyticsClient";
class ConnectionManager { class ConnectionManager {
private localUser!: LocalUser; private localUser!: LocalUser;
@ -78,8 +78,10 @@ class ConnectionManager {
this._currentRoom = null; this._currentRoom = null;
if (connexionType === GameConnexionTypes.login) { if (connexionType === GameConnexionTypes.login) {
this._currentRoom = await Room.createRoom(new URL(localUserStore.getLastRoomUrl())); this._currentRoom = await Room.createRoom(new URL(localUserStore.getLastRoomUrl()));
this.loadOpenIDScreen(); if (this.loadOpenIDScreen() !== null) {
return Promise.reject(new Error("You will be redirect on login page")); return Promise.reject(new Error("You will be redirect on login page"));
}
urlManager.pushRoomIdToUrl(this._currentRoom);
} else if (connexionType === GameConnexionTypes.jwt) { } else if (connexionType === GameConnexionTypes.jwt) {
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get("code"); const code = urlParams.get("code");
@ -188,7 +190,7 @@ class ConnectionManager {
return Promise.reject(new Error("Invalid URL")); return Promise.reject(new Error("Invalid URL"));
} }
if (this.localUser) { if (this.localUser) {
analyticsClient.identifyUser(this.localUser.uuid) analyticsClient.identifyUser(this.localUser.uuid);
} }
this.serviceWorker = new _ServiceWorker(); this.serviceWorker = new _ServiceWorker();

View File

@ -27,12 +27,12 @@ export class AuthenticateController extends BaseController {
console.warn("/message request was aborted"); console.warn("/message request was aborted");
}); });
try {
const { nonce, state, playUri } = parse(req.getQuery()); const { nonce, state, playUri } = parse(req.getQuery());
if (!state || !nonce) { if (!state || !nonce) {
res.writeStatus("400 Unauthorized").end("missing state and nonce URL parameters"); throw "missing state and nonce URL parameters";
return;
} }
try {
const loginUri = await openIDClient.authorizationUrl( const loginUri = await openIDClient.authorizationUrl(
state as string, state as string,
nonce as string, nonce as string,
@ -42,6 +42,7 @@ export class AuthenticateController extends BaseController {
res.writeHeader("Location", loginUri); res.writeHeader("Location", loginUri);
return res.end(); return res.end();
} catch (e) { } catch (e) {
console.error("openIDLogin => e", e);
return this.errorToResponse(e, res); return this.errorToResponse(e, res);
} }
}); });