Working on integration of the woka-list with the new admin endpoint.
This commit is contained in:
@@ -68,7 +68,7 @@ export class AuthenticateController extends BaseHttpController {
|
||||
);
|
||||
res.status(302);
|
||||
res.setHeader("Location", loginUri);
|
||||
return res;
|
||||
return res.send("");
|
||||
} catch (e) {
|
||||
console.error("openIDLogin => e", e);
|
||||
this.castErrorToResponse(e, res);
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import { BaseHttpController } from "./BaseHttpController";
|
||||
import { wokaService } from "../Services/WokaService";
|
||||
import * as tg from "generic-type-guard";
|
||||
import { jwtTokenManager } from "../Services/JWTTokenManager";
|
||||
|
||||
export class WokaListController extends BaseHttpController {
|
||||
routes() {
|
||||
this.app.options("/woka/list/:roomUrl", {}, async (req, res) => {
|
||||
res.status(200).send("");
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
this.app.get("/woka/list/:roomId", {}, async (req, res) => {
|
||||
this.app.get("/woka/list/:roomUrl", {}, async (req, res) => {
|
||||
const token = req.header("Authorization");
|
||||
|
||||
if (!token) {
|
||||
@@ -13,12 +18,19 @@ export class WokaListController extends BaseHttpController {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const jwtData = jwtTokenManager.verifyJWTToken(token);
|
||||
// Let's set the "uuid" param
|
||||
req.params["uuid"] = jwtData.identifier;
|
||||
} catch (e) {
|
||||
console.error("Connection refused for token: " + token, e);
|
||||
res.status(401).send("Invalid token sent");
|
||||
return;
|
||||
}
|
||||
|
||||
const isParameters = new tg.IsInterface()
|
||||
.withProperties({
|
||||
roomId: tg.isString,
|
||||
})
|
||||
.withOptionalProperties({
|
||||
messages: tg.isArray(tg.isUnknown),
|
||||
roomUrl: tg.isString,
|
||||
})
|
||||
.get();
|
||||
|
||||
@@ -26,8 +38,8 @@ export class WokaListController extends BaseHttpController {
|
||||
return res.status(400).send("Unknown parameters");
|
||||
}
|
||||
|
||||
const roomId = req.path_parameters.roomId;
|
||||
const wokaList = await wokaService.getWokaList(roomId, token);
|
||||
const roomUrl = decodeURIComponent(req.path_parameters.roomUrl);
|
||||
const wokaList = await wokaService.getWokaList(roomUrl, req.params["uuid"]);
|
||||
|
||||
if (!wokaList) {
|
||||
return res.status(500).send("Error on getting woka list");
|
||||
|
||||
@@ -10,6 +10,7 @@ export function cors(req: Request, res: Response, next?: MiddlewareNext): Middle
|
||||
);
|
||||
res.setHeader("access-control-allow-methods", "GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
res.setHeader("access-control-allow-origin", FRONT_URL);
|
||||
res.setHeader("access-control-allow-credentials", "true");
|
||||
|
||||
if (next) {
|
||||
next();
|
||||
|
||||
@@ -7,10 +7,14 @@ class AdminWokaService implements WokaServiceInterface {
|
||||
/**
|
||||
* Returns the list of all available Wokas for the current user.
|
||||
*/
|
||||
getWokaList(roomId: string, token: string): Promise<WokaList | undefined> {
|
||||
getWokaList(roomUrl: string, token: string): Promise<WokaList | undefined> {
|
||||
return axios
|
||||
.get(`${ADMIN_API_URL}/api/woka/list/${roomId}/${token}`, {
|
||||
.get(`${ADMIN_API_URL}/api/woka/list`, {
|
||||
headers: { Authorization: `${ADMIN_API_TOKEN}` },
|
||||
params: {
|
||||
roomUrl,
|
||||
uuid: token,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
if (isWokaList(res.data)) {
|
||||
|
||||
Reference in New Issue
Block a user