mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-08 08:34:20 +02:00
Add possibility to download access/dbAnonyized.json
This commit is contained in:
parent
c536632a51
commit
ba0753b85a
@ -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")
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user