mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-10 01:24: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 {
|
function idADev(v: Volunteer | PreVolunteer): boolean {
|
||||||
if (((v as Volunteer)?.roles || []).includes("dev")) {
|
|
||||||
console.log(v.lastname)
|
|
||||||
}
|
|
||||||
return ((v as Volunteer)?.roles || []).includes("dev")
|
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 {
|
return {
|
||||||
id: volunteer.id,
|
id: volunteer.id,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import path from "path"
|
import path from "path"
|
||||||
import express, { RequestHandler } from "express"
|
import express, { RequestHandler, Request, Response, NextFunction } from "express"
|
||||||
import logger from "morgan"
|
import logger from "morgan"
|
||||||
import cookieParser from "cookie-parser"
|
import cookieParser from "cookie-parser"
|
||||||
import compression from "compression"
|
import compression from "compression"
|
||||||
@ -66,6 +66,15 @@ if (__DEV__) devServer(app)
|
|||||||
app.use(express.json())
|
app.use(express.json())
|
||||||
app.use(cookieParser())
|
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
|
* APIs
|
||||||
*/
|
*/
|
||||||
|
@ -64,9 +64,9 @@ async function getSecret() {
|
|||||||
return cachedSecret
|
return cachedSecret
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getJwt(id: number): Promise<string> {
|
export async function getJwt(id: number, roles: string[]): Promise<string> {
|
||||||
const jwt = sign(
|
const jwt = sign(
|
||||||
{ id },
|
{ id, roles },
|
||||||
await getSecret()
|
await getSecret()
|
||||||
// __TEST__
|
// __TEST__
|
||||||
// ? undefined
|
// ? undefined
|
||||||
|
Loading…
x
Reference in New Issue
Block a user