This commit is contained in:
Gregoire Parant 2021-03-01 22:32:50 +01:00
parent 30f4793342
commit 915d945dd5
2 changed files with 8 additions and 11 deletions

View File

@ -182,15 +182,15 @@ export class IoSocketController {
}*/ }*/
if (ADMIN_API_URL) { if (ADMIN_API_URL) {
try { try {
let userData = { let userData : FetchMemberDataByUuidResponse = {
uuid: v4(), uuid: v4(),
anonymous: true,
tags: [], tags: [],
textures: [], textures: [],
messages: [], messages: [],
anonymous: true
}; };
try { try {
(userData as FetchMemberDataByUuidResponse) = await adminApi.fetchMemberDataByUuid(userUuid); userData = await adminApi.fetchMemberDataByUuid(userUuid);
}catch (err){ }catch (err){
if (err?.response?.status == 404) { if (err?.response?.status == 404) {
// If we get an HTTP 404, the token is invalid. Let's perform an anonymous login! // If we get an HTTP 404, the token is invalid. Let's perform an anonymous login!

View File

@ -30,6 +30,7 @@ export interface FetchMemberDataByUuidResponse {
tags: string[]; tags: string[];
textures: CharacterTexture[]; textures: CharacterTexture[];
messages: unknown[]; messages: unknown[];
anonymous?: boolean;
} }
class AdminApi { class AdminApi {
@ -61,14 +62,10 @@ class AdminApi {
if (!ADMIN_API_URL) { if (!ADMIN_API_URL) {
return Promise.reject('No admin backoffice set!'); return Promise.reject('No admin backoffice set!');
} }
try { const res = await Axios.get(ADMIN_API_URL+'/api/membership/'+uuid,
const res = await Axios.get(ADMIN_API_URL+'/api/membership/'+uuid, { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} }
{ headers: {"Authorization" : `${ADMIN_API_TOKEN}`} } )
) return res.data;
return res.data;
} catch (e) {
throw e;
}
} }
async fetchMemberDataByToken(organizationMemberToken: string): Promise<AdminApiData> { async fetchMemberDataByToken(organizationMemberToken: string): Promise<AdminApiData> {