fix worlds endpoint
This commit is contained in:
parent
99619cf140
commit
9b84c94579
@ -109,16 +109,12 @@ export class MapController extends BaseController {
|
||||
res.onAborted(() => {
|
||||
console.warn("/message request was aborted");
|
||||
});
|
||||
const { userIdentify, token } = parse(req.getQuery());
|
||||
const { token } = parse(req.getQuery());
|
||||
try {
|
||||
//verify connected by token
|
||||
if (token != undefined) {
|
||||
try {
|
||||
const authTokenData: AuthTokenData = jwtTokenManager.verifyJWTToken(token as string, false);
|
||||
if (authTokenData.hydraAccessToken == undefined) {
|
||||
throw Error("Token cannot to be check on Hydra");
|
||||
}
|
||||
|
||||
jwtTokenManager.verifyJWTToken(token as string, false);
|
||||
const result: any[] = [];
|
||||
for (const room of socketManager.getWorlds().values()) {
|
||||
const world: any = {};
|
||||
@ -135,15 +131,21 @@ export class MapController extends BaseController {
|
||||
result.push(world);
|
||||
}
|
||||
|
||||
return res
|
||||
.writeStatus("200 OK")
|
||||
.writeHeader("Content-Type", "application/json")
|
||||
.end(
|
||||
res.writeStatus("200 OK");
|
||||
res.writeHeader("Content-Type", "application/json");
|
||||
this.addCorsHeaders(res);
|
||||
res.end(
|
||||
JSON.stringify({ worlds: result })
|
||||
);
|
||||
} catch (error) {
|
||||
return this.errorToResponse(error, res);
|
||||
res.writeStatus("403 FORBIDDEN");
|
||||
this.addCorsHeaders(res);
|
||||
res.end();
|
||||
}
|
||||
} else {
|
||||
res.writeStatus("401 UNAUTHORIZED");
|
||||
this.addCorsHeaders(res);
|
||||
res.end();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("getWorlds => ERROR", error);
|
||||
|
Loading…
Reference in New Issue
Block a user