fix wrong query condition preventing users from accessing surveys shared with anyone
Closes #20
This commit is contained in:
parent
457249c4e3
commit
5b39c03a7d
1 changed files with 2 additions and 1 deletions
|
@ -20,7 +20,8 @@ export async function loadSurveyMetadata(surveyId: SurveyId, userId: UserId): Pr
|
|||
const surveys = await db.select()
|
||||
.from(surveyPermissionsTable)
|
||||
.innerJoin(surveysTable, eq(surveysTable.id, surveyPermissionsTable.surveyId))
|
||||
.where(and(eq(surveysTable.id, surveyId), eq(surveyPermissionsTable.user, userId))).limit(1);
|
||||
.where(and(eq(surveysTable.id, surveyId),
|
||||
or(eq(surveyPermissionsTable.user, userId), isNull(surveyPermissionsTable.user)))).limit(1);
|
||||
|
||||
if (surveys.length === 0) {
|
||||
return null;
|
||||
|
|
Loading…
Add table
Reference in a new issue