Add possibility to download access/dbAnonyized.json

This commit is contained in:
pikiou 2022-03-11 01:28:50 +01:00
parent c536632a51
commit ba0753b85a
4 changed files with 13 additions and 7 deletions

View File

@ -273,9 +273,6 @@ function anonimizedDb(_s: States): States {
}
function idADev(v: Volunteer | PreVolunteer): boolean {
if (((v as Volunteer)?.roles || []).includes("dev")) {
console.log(v.lastname)
}
return ((v as Volunteer)?.roles || []).includes("dev")
}

View File

@ -48,7 +48,7 @@ export const volunteerLogin = expressAccessor.get<VolunteerLogin>(async (list, b
}
}
const jwt = await getJwt(volunteer.id)
const jwt = await getJwt(volunteer.id, volunteer.roles)
return {
id: volunteer.id,

View File

@ -1,5 +1,5 @@
import path from "path"
import express, { RequestHandler } from "express"
import express, { RequestHandler, Request, Response, NextFunction } from "express"
import logger from "morgan"
import cookieParser from "cookie-parser"
import compression from "compression"
@ -66,6 +66,15 @@ if (__DEV__) devServer(app)
app.use(express.json())
app.use(cookieParser())
// Anonymized DB download
app.get(
"/OUpere3yzML8da8abw5Tyeef2P0LJOetmdDHfKZC0T2CU/dbAnonymized.json",
async (_request: Request, response: Response, _next: NextFunction): Promise<void> => {
const file = path.resolve(`access/dbAnonymized.json`)
response.download(file)
}
)
/**
* APIs
*/

View File

@ -64,9 +64,9 @@ async function getSecret() {
return cachedSecret
}
export async function getJwt(id: number): Promise<string> {
export async function getJwt(id: number, roles: string[]): Promise<string> {
const jwt = sign(
{ id },
{ id, roles },
await getSecret()
// __TEST__
// ? undefined