Linting app

This commit is contained in:
David Négrier 2020-09-29 16:12:17 +02:00
parent b485c9bf46
commit 432b4a0e85
7 changed files with 46 additions and 42 deletions

View file

@ -12,27 +12,29 @@ export class AdminController {
getLoginUrlByToken(){
this.App.get("/register/:token", async (res: HttpResponse, req: HttpRequest) => {
if (!ADMIN_API_URL) {
return res.writeStatus("500 Internal Server Error").end('No admin backoffice set!');
}
this.App.get("/register/:token", (res: HttpResponse, req: HttpRequest) => {
(async () => {
if (!ADMIN_API_URL) {
return res.writeStatus("500 Internal Server Error").end('No admin backoffice set!');
}
const query = parse(req.getQuery());
const query = parse(req.getQuery());
const token:string = query.token as string;
const token:string = query.token as string;
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');
}
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.writeStatus("200 OK").end(JSON.stringify({organizationSlug, worldSlug, roomSlug}));
const organizationSlug = response.data.organizationSlug;
const worldSlug = response.data.worldSlug;
const roomSlug = response.data.roomSlug;
res.writeStatus("200 OK").end(JSON.stringify({organizationSlug, worldSlug, roomSlug}));
})();
});
}
}

View file

@ -39,20 +39,22 @@ export class AuthenticateController extends BaseController {
res.end();
});
this.App.post("/login", async (res: HttpResponse, req: HttpRequest) => {
this.addCorsHeaders(res);
this.App.post("/login", (res: HttpResponse, req: HttpRequest) => {
(async () => {
this.addCorsHeaders(res);
res.onAborted(() => {
console.warn('Login request was aborted');
})
const param = await res.json();
const userUuid = uuid();
const token = Jwt.sign({name: param.name, userUuid: userUuid} as TokenInterface, SECRET_KEY, {expiresIn: '24h'});
res.writeStatus("200 OK").end(JSON.stringify({
token: token,
mapUrlStart: URL_ROOM_STARTED,
userId: userUuid,
}));
res.onAborted(() => {
console.warn('Login request was aborted');
})
const param = await res.json();
const userUuid = uuid();
const token = Jwt.sign({name: param.name, userUuid: userUuid} as TokenInterface, SECRET_KEY, {expiresIn: '24h'});
res.writeStatus("200 OK").end(JSON.stringify({
token: token,
mapUrlStart: URL_ROOM_STARTED,
userId: userUuid,
}));
})();
});
}
}