HotFix authentication manager to get data from back
Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
This commit is contained in:
parent
6fafb727ba
commit
e54732be1b
4 changed files with 23 additions and 9 deletions
|
@ -226,7 +226,7 @@ class ConnectionManager {
|
||||||
|
|
||||||
public async anonymousLogin(isBenchmark: boolean = false): Promise<void> {
|
public async anonymousLogin(isBenchmark: boolean = false): Promise<void> {
|
||||||
const data = await Axios.post(`${PUSHER_URL}/anonymLogin`).then((res) => res.data);
|
const data = await Axios.post(`${PUSHER_URL}/anonymLogin`).then((res) => res.data);
|
||||||
this.localUser = new LocalUser(data.userUuid, []);
|
this.localUser = new LocalUser(data.userUuid, [], data.email);
|
||||||
this.authToken = data.authToken;
|
this.authToken = data.authToken;
|
||||||
if (!isBenchmark) {
|
if (!isBenchmark) {
|
||||||
// In benchmark, we don't have a local storage.
|
// In benchmark, we don't have a local storage.
|
||||||
|
|
|
@ -63,25 +63,30 @@ export class AuthenticateController extends BaseController {
|
||||||
if (token != undefined) {
|
if (token != undefined) {
|
||||||
try {
|
try {
|
||||||
const authTokenData: AuthTokenData = jwtTokenManager.verifyJWTToken(token as string, false);
|
const authTokenData: AuthTokenData = jwtTokenManager.verifyJWTToken(token as string, false);
|
||||||
|
|
||||||
|
//Get user data from Admin Back Office
|
||||||
|
//This is very important to create User Local in LocalStorage in WorkAdventure
|
||||||
|
const resUserData = await this.getUserByUserIdentifier(
|
||||||
|
authTokenData.identifier,
|
||||||
|
playUri as string,
|
||||||
|
IPAddress
|
||||||
|
);
|
||||||
|
|
||||||
if (authTokenData.accessToken == undefined) {
|
if (authTokenData.accessToken == undefined) {
|
||||||
//if not nonce and code, user connected in anonymous
|
//if not nonce and code, user connected in anonymous
|
||||||
//get data with identifier and return token
|
//get data with identifier and return token
|
||||||
if (!code && !nonce) {
|
if (!code && !nonce) {
|
||||||
const data = await this.getUserByUserIdentifier(
|
|
||||||
authTokenData.identifier,
|
|
||||||
playUri as string,
|
|
||||||
IPAddress
|
|
||||||
);
|
|
||||||
res.writeStatus("200");
|
res.writeStatus("200");
|
||||||
this.addCorsHeaders(res);
|
this.addCorsHeaders(res);
|
||||||
return res.end(JSON.stringify({ ...data, authToken: token }));
|
return res.end(JSON.stringify({ ...resUserData, authToken: token }));
|
||||||
}
|
}
|
||||||
throw Error("Token cannot to be check on Hydra");
|
throw Error("Token cannot to be check on Hydra");
|
||||||
}
|
}
|
||||||
|
|
||||||
const resCheckTokenAuth = await openIDClient.checkTokenAuth(authTokenData.accessToken);
|
const resCheckTokenAuth = await openIDClient.checkTokenAuth(authTokenData.accessToken);
|
||||||
res.writeStatus("200");
|
res.writeStatus("200");
|
||||||
this.addCorsHeaders(res);
|
this.addCorsHeaders(res);
|
||||||
return res.end(JSON.stringify({ ...resCheckTokenAuth, authToken: token }));
|
return res.end(JSON.stringify({ ...resCheckTokenAuth, ...resUserData, authToken: token }));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.info("User was not connected", err);
|
console.info("User was not connected", err);
|
||||||
}
|
}
|
||||||
|
@ -261,7 +266,14 @@ export class AuthenticateController extends BaseController {
|
||||||
playUri: string,
|
playUri: string,
|
||||||
IPAddress: string
|
IPAddress: string
|
||||||
): Promise<FetchMemberDataByUuidResponse | object> {
|
): Promise<FetchMemberDataByUuidResponse | object> {
|
||||||
let data: FetchMemberDataByUuidResponse | object = {};
|
let data: FetchMemberDataByUuidResponse = {
|
||||||
|
email: email,
|
||||||
|
userUuid: email,
|
||||||
|
tags: [],
|
||||||
|
messages: [],
|
||||||
|
visitCardUrl: null,
|
||||||
|
textures: [],
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
data = await adminApi.fetchMemberDataByUuid(email, playUri, IPAddress);
|
data = await adminApi.fetchMemberDataByUuid(email, playUri, IPAddress);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -189,6 +189,7 @@ export class IoSocketController {
|
||||||
let memberTextures: CharacterTexture[] = [];
|
let memberTextures: CharacterTexture[] = [];
|
||||||
const room = await socketManager.getOrCreateRoom(roomId);
|
const room = await socketManager.getOrCreateRoom(roomId);
|
||||||
let userData: FetchMemberDataByUuidResponse = {
|
let userData: FetchMemberDataByUuidResponse = {
|
||||||
|
email: userIdentifier,
|
||||||
userUuid: userIdentifier,
|
userUuid: userIdentifier,
|
||||||
tags: [],
|
tags: [],
|
||||||
visitCardUrl: null,
|
visitCardUrl: null,
|
||||||
|
|
|
@ -22,6 +22,7 @@ export interface AdminBannedData {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FetchMemberDataByUuidResponse {
|
export interface FetchMemberDataByUuidResponse {
|
||||||
|
email: string;
|
||||||
userUuid: string;
|
userUuid: string;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
visitCardUrl: string | null;
|
visitCardUrl: string | null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue