Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/api/src/projects/dao/project-member-dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ModelRepository } from '@rfcx-bio/node-common/dao/model-repository'
import { type LocationProjectUserRole, type UserProfile } from '@rfcx-bio/node-common/dao/types'

import { getSequelize } from '~/db'
import { BioNotFoundError } from '~/errors'
import { fileUrl } from '~/format-helpers/file-url'
import { getProjectById } from './projects-dao'

Expand Down Expand Up @@ -65,7 +66,8 @@ export const update = async (data: { locationProjectId: number, userId: number,
}

export const getUserRoleForProject = async (userId: number | undefined, projectId: number): Promise<ProjectRole> => {
const projectIsPublished = await getProjectById(projectId).then(p => p?.status === 'published' ?? false)
if (projectId === undefined || Number.isNaN(projectId)) { throw BioNotFoundError() }
const projectIsPublished = (await getProjectById(projectId))?.status === 'published'

// When there is no user (no token) and project is not published, no role
// When there is no user and project is published, set as external
Expand Down