Skip to content

Commit

Permalink
fix: fix password linking sql, closes #43
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcath committed Oct 8, 2024
1 parent 2f6e065 commit edae68a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/routes/app.$assetslug.$entry._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const loader = async ({request, params}: LoaderFunctionArgs) => {
)

const passwords = await time('getPasswords', 'Get Passwords', () =>
prisma.$queryRawTyped(getEntryPasswords(user.role, user.id, entry.id))
prisma.$queryRawTyped(getEntryPasswords(entry.id, user.role, user.id))
)

const values = await time('getValues', 'Get Values', () =>
Expand Down
12 changes: 6 additions & 6 deletions prisma/sql/getEntryPasswords.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
-- @param {String} $1:userRole The role of the current user
-- @param {String} $2:userId The ID of the current user
-- @param {String} $3:entryId
-- @param {String} $1:entryId The ID of the entry
-- @param {String} $2:userRole The role of the current user
-- @param {String} $3:userId The ID of the current user
SELECT
Password.id, Password.title
FROM
Password
WHERE
id IN (SELECT passwordId FROM EntryPassword WHERE EntryPassword.entryId = $3)
id IN (SELECT passwordId FROM EntryPassword WHERE EntryPassword.entryId = $1)
AND
aclId IN (SELECT aclId FROM ACLEntry
WHERE read = true AND (
(type = "role" AND target = $1)
(type = "role" AND target = $2)
OR
(type = "user" AND target = $2)
(type = "user" AND target = $3)
)
)
ORDER BY
Expand Down

0 comments on commit edae68a

Please sign in to comment.