feat: Add admin-only protection to ebook operations
- Update ebook handlers to require admin role for CRUD operations - Modify folder operations to be admin-only - Update ebook scanner to associate books with admin who added them - Add admin ID tracking to CreateEbook operations - Restrict scanner operations to admin users only
This commit is contained in:
@@ -36,6 +36,7 @@ type EbookScanner struct {
|
||||
db *database.Queries
|
||||
watcher *fsnotify.Watcher
|
||||
folders []string
|
||||
adminID pgtype.UUID
|
||||
}
|
||||
|
||||
func NewEbookScanner(db *database.Queries) *EbookScanner {
|
||||
@@ -50,6 +51,10 @@ func NewEbookScanner(db *database.Queries) *EbookScanner {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EbookScanner) SetAdminID(adminID pgtype.UUID) {
|
||||
s.adminID = adminID
|
||||
}
|
||||
|
||||
func (s *EbookScanner) SetFolders(folders []string) error {
|
||||
s.folders = folders
|
||||
|
||||
@@ -291,6 +296,7 @@ func (s *EbookScanner) processEbookFile(ctx context.Context, path string) error
|
||||
DatePublished: pgtype.Date{Time: metadata.PublishDate, Valid: !metadata.PublishDate.IsZero()},
|
||||
Contributors: pgtype.Text{String: metadata.Contributors, Valid: metadata.Contributors != ""},
|
||||
Tags: pgtype.Text{String: metadata.Tags, Valid: metadata.Tags != ""},
|
||||
AddedByAdminID: s.adminID,
|
||||
})
|
||||
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user