fix(persistence): show all genres to admins without user_library rows (#6502)

This commit is contained in:
Deluan Quintão 2026-11-18 09:17:14 -05:00 committed by GitHub
parent 2f85c631bf
commit ebdf2dc693
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -170,9 +170,9 @@ func (r *baseTagRepository) applyLibraryFiltering(ctx context.Context, sq Select
// Add library_tag join
sq = sq.LeftJoin("library_tag on library_tag.tag_id = tag.id")
// For authenticated users, also join with user_library to filter by accessible libraries
// Non-admins only see tags from libraries they are assigned to
user := loggedUser(ctx)
if user.ID != invalidUserId {
if user.ID != invalidUserId && !user.IsAdmin {
sq = sq.Join("user_library on user_library.library_id = library_tag.library_id AND user_library.user_id = ?", user.ID)
}

View File

@ -144,9 +144,10 @@ var _ = Describe("Tag Library Filtering", func() {
}
Context("Admin User", func() {
It("should see all tags regardless of library", func() {
tags := readAllTags(&adminUser)
Expect(tags).To(HaveLen(3))
It("should see all tags even without user_library assignments", func() {
unassignedAdmin := model.User{ID: "admin-without-libraries", IsAdmin: true}
Expect(readAllTags(&unassignedAdmin)).To(HaveLen(3))
Expect(countTags(&unassignedAdmin)).To(Equal(int64(3)))
})
})