mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Fix request.user typing
This commit is contained in:
@@ -11,7 +11,7 @@ import { Role } from '../../../frontend/src/types'
|
||||
declare module 'express-serve-static-core' {
|
||||
interface Request {
|
||||
token?: string | null
|
||||
user: User
|
||||
user?: User
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { fixBigInt } from '../utils/common'
|
||||
import { Role, calculateMeanHypsodonty } from '../../../frontend/src/types'
|
||||
import { AccessError } from '../middlewares/authorizer'
|
||||
|
||||
export const getLocalitySpeciesList = async (lids: number[], user: User) => {
|
||||
export const getLocalitySpeciesList = async (lids: number[], user: User | undefined) => {
|
||||
// Get localities separately with getAllLocalities to know which localities user has access to.
|
||||
// Unoptimal, if it's slow try a different way.
|
||||
const localityList = await getAllLocalities(user)
|
||||
@@ -248,10 +248,7 @@ export const getLocalityDetails = async (id: number, user: User | undefined) =>
|
||||
if (!user) throw new AccessError()
|
||||
if (![Role.Admin, Role.EditUnrestricted].includes(user.role)) {
|
||||
const usersProjects = await getIdsOfUsersProjects(user)
|
||||
if (!result.now_plr.find(proj => usersProjects.has(proj.pid)))
|
||||
throw new AccessError(
|
||||
'The requested locality is in draft status and the user has no required rights or project association to it.'
|
||||
)
|
||||
if (!result.now_plr.find(proj => usersProjects.has(proj.pid))) throw new AccessError()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user