Implement all use of AdminService

Implement and generalize adminApi and localAdmin from adminInterface
This commit is contained in:
CEC
2022-04-14 11:33:00 +02:00
parent 5507a91d48
commit 317e0d3787
7 changed files with 197 additions and 114 deletions
@@ -1,6 +1,5 @@
import { v4 } from "uuid";
import { BaseHttpController } from "./BaseHttpController";
import { adminApi } from "../Services/AdminApi";
import { AuthTokenData, jwtTokenManager } from "../Services/JWTTokenManager";
import { parse } from "query-string";
import { openIDClient } from "../Services/OpenIDClient";
@@ -320,7 +319,7 @@ export class AuthenticateController extends BaseHttpController {
(async () => {
const param = await req.json();
adminApi.setLocale(req.header("accept-language"));
adminService.locale = req.header("accept-language");
//todo: what to do if the organizationMemberToken is already used?
const organizationMemberToken: string | null = param.organizationMemberToken;
@@ -328,13 +327,15 @@ export class AuthenticateController extends BaseHttpController {
try {
if (typeof organizationMemberToken != "string") throw new Error("No organization token");
const data = await adminApi.fetchMemberDataByToken(organizationMemberToken, playUri);
const data = await adminService.fetchMemberDataByToken(organizationMemberToken, playUri);
const userUuid = data.userUuid;
const email = data.email;
const roomUrl = data.roomUrl;
const mapUrlStart = data.mapUrlStart;
const authToken = jwtTokenManager.createAuthToken(email || userUuid);
console.info(data);
res.json({
authToken,
userUuid,
@@ -420,7 +421,7 @@ export class AuthenticateController extends BaseHttpController {
//get login profile
res.status(302);
res.setHeader("Location", adminApi.getProfileUrl(authTokenData.accessToken));
res.setHeader("Location", adminService.getProfileUrl(authTokenData.accessToken));
res.send("");
return;
} catch (error) {