Skip to content

Commit

Permalink
fix: Organisation access for admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Veikkosuhonen committed Mar 11, 2024
1 parent 98817dc commit 8a12614
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/server/routes/organisations/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ const getAccessAndOrganisation = async (user, code, requiredAccess) => {
const { access, organisation: organisationByAccess } =
organisationAccess.find(({ organisation }) => organisation.code === code) ?? {}
// eslint-disable-next-line no-nested-ternary
const organisation = organisationByAccess
? organisationAccess
: user.isAdmin
? await Organisation.findOne({ where: { code } })
: null
const organisation = organisationByAccess || (user.isAdmin ? await Organisation.findOne({ where: { code } }) : null)

const hasReadAccess = user.isAdmin || Boolean(access?.read)
const hasWriteAccess = user.isAdmin || Boolean(access?.write)
Expand Down

0 comments on commit 8a12614

Please sign in to comment.