Merge branch 'develop' of github.com:thecodingmachine/workadventure into protobuf
# Conflicts: # back/package.json
This commit is contained in:
commit
cd083a2090
7 changed files with 90 additions and 3 deletions
36
back/src/Controller/AdminController.ts
Normal file
36
back/src/Controller/AdminController.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import {Application, Request, Response} from "express";
|
||||
import {OK} from "http-status-codes";
|
||||
import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable";
|
||||
import Axios from "axios";
|
||||
|
||||
export class AdminController {
|
||||
App : Application;
|
||||
|
||||
constructor(App : Application) {
|
||||
this.App = App;
|
||||
this.getLoginUrlByToken();
|
||||
}
|
||||
|
||||
|
||||
getLoginUrlByToken(){
|
||||
this.App.get("/register/:token", async (req: Request, res: Response) => {
|
||||
if (!ADMIN_API_URL) {
|
||||
return res.status(500).send('No admin backoffice set!');
|
||||
}
|
||||
const token:string = req.params.token;
|
||||
|
||||
let response = null
|
||||
try {
|
||||
response = await Axios.get(ADMIN_API_URL+'/api/login-url/'+token, { headers: {"Authorization" : `${ADMIN_API_TOKEN}`} })
|
||||
} catch (e) {
|
||||
console.log(e.message)
|
||||
return res.status(e.status || 500).send('An error happened');
|
||||
}
|
||||
|
||||
const organizationSlug = response.data.organizationSlug;
|
||||
const worldSlug = response.data.worldSlug;
|
||||
const roomSlug = response.data.roomSlug;
|
||||
return res.status(OK).send({organizationSlug, worldSlug, roomSlug});
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue