From 3a17795ad33bdbcc95d1b420ff179a560f60c2f5 Mon Sep 17 00:00:00 2001 From: arp Date: Fri, 18 Sep 2020 15:48:30 +0200 Subject: [PATCH] added basic token auth --- back/src/Controller/AdminController.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/back/src/Controller/AdminController.ts b/back/src/Controller/AdminController.ts index d6f1d23d..7c20498f 100644 --- a/back/src/Controller/AdminController.ts +++ b/back/src/Controller/AdminController.ts @@ -1,6 +1,6 @@ import {Application, Request, Response} from "express"; import {OK} from "http-status-codes"; -import {ADMIN_API_URL} from "../Enum/EnvironmentVariable"; +import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable"; import Axios, {AxiosError} from "axios"; export class AdminController { @@ -19,14 +19,12 @@ export class AdminController { } const token:string = req.params.token; - //todo add ADMIN_API_TOKEN authorization let response = null try { - console.log(ADMIN_API_URL+'/api/login-url/'+token); - response = await Axios.get(ADMIN_API_URL+'/api/login-url/'+token) + 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(500).send('An error happened'); + return res.status(e.status || 500).send('An error happened'); } const teamSlug = response.data.teamSlug;