diff --git a/backend/src/api/routes/bookmarks.py b/backend/src/api/routes/bookmarks.py
index bd6e8c8..39541e5 100644
--- a/backend/src/api/routes/bookmarks.py
+++ b/backend/src/api/routes/bookmarks.py
@@ -75,8 +75,8 @@ async def create_bookmark(
detail="Document not found"
)
- # 문서 접근 권한 확인
- if not document.is_public and document.uploaded_by != current_user.id and not current_user.is_admin:
+ # 문서 접근 권한 확인 (관리자 또는 문서 관리 권한이 있으면 모든 문서 접근 가능)
+ if not (current_user.is_admin or current_user.can_manage_books) and not document.is_public and document.uploaded_by != current_user.id:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Not enough permissions to access this document"
@@ -155,8 +155,8 @@ async def get_document_bookmarks(
detail="Document not found"
)
- # 문서 접근 권한 확인
- if not document.is_public and document.uploaded_by != current_user.id and not current_user.is_admin:
+ # 문서 접근 권한 확인 (관리자 또는 문서 관리 권한이 있으면 모든 문서 접근 가능)
+ if not (current_user.is_admin or current_user.can_manage_books) and not document.is_public and document.uploaded_by != current_user.id:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Not enough permissions to access this document"
diff --git a/backend/src/api/routes/document_links.py b/backend/src/api/routes/document_links.py
index bec63ed..e4c75a4 100644
--- a/backend/src/api/routes/document_links.py
+++ b/backend/src/api/routes/document_links.py
@@ -109,8 +109,8 @@ async def create_document_link(
detail="Source document not found"
)
- # 권한 확인
- if not source_doc.is_public and source_doc.uploaded_by != current_user.id and not current_user.is_admin:
+ # 권한 확인 (관리자 또는 문서 관리 권한이 있으면 모든 문서 접근 가능)
+ if not (current_user.is_admin or current_user.can_manage_books) and not source_doc.is_public and source_doc.uploaded_by != current_user.id:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Access denied to source document"
@@ -146,7 +146,7 @@ async def create_document_link(
# 대상 문서/노트 권한 확인
if target_doc:
- if not target_doc.is_public and target_doc.uploaded_by != current_user.id and not current_user.is_admin:
+ if not (current_user.is_admin or current_user.can_manage_books) and not target_doc.is_public and target_doc.uploaded_by != current_user.id:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Access denied to target document"
@@ -235,8 +235,8 @@ async def get_document_links(
detail="Document not found"
)
- # 권한 확인
- if not document.is_public and document.uploaded_by != current_user.id and not current_user.is_admin:
+ # 권한 확인 (관리자 또는 문서 관리 권한이 있으면 모든 문서 접근 가능)
+ if not (current_user.is_admin or current_user.can_manage_books) and not document.is_public and document.uploaded_by != current_user.id:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Access denied"
@@ -345,8 +345,8 @@ async def get_linkable_documents(
and_(
Document.html_path.isnot(None), # HTML 문서만
Document.id != document_id, # 자기 자신 제외
- # 권한 확인: 공개 문서이거나 본인이 업로드한 문서
- (Document.is_public == True) | (Document.uploaded_by == current_user.id) | (current_user.is_admin == True)
+ # 권한 확인: 공개 문서이거나 본인이 업로드한 문서이거나 문서 관리 권한이 있음
+ (Document.is_public == True) | (Document.uploaded_by == current_user.id) | (current_user.is_admin == True) | (current_user.can_manage_books == True)
)
).order_by(
# 같은 서적 우선, 그 다음 정렬 순서
@@ -522,8 +522,8 @@ async def get_document_backlinks(
print(f"✅ 문서 찾음: {document.title}")
- # 권한 확인
- if not document.is_public and document.uploaded_by != current_user.id and not current_user.is_admin:
+ # 권한 확인 (관리자 또는 문서 관리 권한이 있으면 모든 문서 접근 가능)
+ if not (current_user.is_admin or current_user.can_manage_books) and not document.is_public and document.uploaded_by != current_user.id:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Access denied"
@@ -541,8 +541,8 @@ async def get_document_backlinks(
).outerjoin(Book, Document.book_id == Book.id).where(
and_(
DocumentLink.target_document_id == document_id,
- # 권한 확인: 공개 문서이거나 본인이 업로드한 문서
- (Document.is_public == True) | (Document.uploaded_by == current_user.id) | (current_user.is_admin == True)
+ # 권한 확인: 공개 문서이거나 본인이 업로드한 문서이거나 문서 관리 권한이 있음
+ (Document.is_public == True) | (Document.uploaded_by == current_user.id) | (current_user.is_admin == True) | (current_user.can_manage_books == True)
)
).order_by(DocumentLink.created_at.desc())
@@ -650,8 +650,8 @@ async def get_document_link_fragments(
detail="Document not found"
)
- # 권한 확인
- if not document.is_public and document.uploaded_by != current_user.id and not current_user.is_admin:
+ # 권한 확인 (관리자 또는 문서 관리 권한이 있으면 모든 문서 접근 가능)
+ if not (current_user.is_admin or current_user.can_manage_books) and not document.is_public and document.uploaded_by != current_user.id:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Access denied"
@@ -663,8 +663,8 @@ async def get_document_link_fragments(
).where(
and_(
DocumentLink.source_document_id == document_id,
- # 권한 확인: 공개 문서이거나 본인이 업로드한 문서
- (Document.is_public == True) | (Document.uploaded_by == current_user.id) | (current_user.is_admin == True)
+ # 권한 확인: 공개 문서이거나 본인이 업로드한 문서이거나 문서 관리 권한이 있음
+ (Document.is_public == True) | (Document.uploaded_by == current_user.id) | (current_user.is_admin == True) | (current_user.can_manage_books == True)
)
).order_by(DocumentLink.start_offset.asc())
diff --git a/backend/src/api/routes/documents.py b/backend/src/api/routes/documents.py
index 103a6e1..eb67c17 100644
--- a/backend/src/api/routes/documents.py
+++ b/backend/src/api/routes/documents.py
@@ -98,8 +98,8 @@ async def list_documents(
selectinload(Document.category) # 소분류 정보 추가
)
- # 권한 필터링 (관리자가 아니면 공개 문서 + 자신이 업로드한 문서만)
- if not current_user.is_admin:
+ # 권한 필터링 (관리자 또는 문서 관리 권한이 있으면 모든 문서, 아니면 공개 문서 + 자신이 업로드한 문서만)
+ if not (current_user.is_admin or current_user.can_manage_books):
query = query.where(
or_(
Document.is_public == True,
@@ -175,8 +175,8 @@ async def list_all_documents(
selectinload(Document.category) # 소분류 정보 추가
)
- # 권한 필터링 (관리자가 아니면 공개 문서 + 자신이 업로드한 문서만)
- if not current_user.is_admin:
+ # 권한 필터링 (관리자 또는 문서 관리 권한이 있으면 모든 문서, 아니면 공개 문서 + 자신이 업로드한 문서만)
+ if not (current_user.is_admin or current_user.can_manage_books):
query = query.where(
or_(
Document.is_public == True,
@@ -514,8 +514,8 @@ async def get_document(
detail="Document not found"
)
- # 권한 확인
- if not document.is_public and document.uploaded_by != current_user.id and not current_user.is_admin:
+ # 권한 확인 (관리자 또는 문서 관리 권한이 있으면 모든 문서 접근 가능)
+ if not (current_user.is_admin or current_user.can_manage_books) and not document.is_public and document.uploaded_by != current_user.id:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Not enough permissions"
@@ -616,9 +616,9 @@ async def get_document_pdf(
print(f"🔐 문서 권한: is_public={document.is_public}, uploaded_by={document.uploaded_by}")
print(f"👤 사용자 권한: is_admin={current_user.is_admin}, user_id={current_user.id}")
- # 권한 확인
- if not current_user.is_admin and not document.is_public and document.uploaded_by != current_user.id:
- print(f"❌ 접근 권한 없음 - 관리자: {current_user.is_admin}, 공개: {document.is_public}, 소유자: {document.uploaded_by == current_user.id}")
+ # 권한 확인 (관리자 또는 문서 관리 권한이 있으면 모든 문서 접근 가능)
+ if not (current_user.is_admin or current_user.can_manage_books) and not document.is_public and document.uploaded_by != current_user.id:
+ print(f"❌ 접근 권한 없음 - 관리자: {current_user.is_admin}, 문서권한: {current_user.can_manage_books}, 공개: {document.is_public}, 소유자: {document.uploaded_by == current_user.id}")
raise HTTPException(status_code=403, detail="Access denied")
# PDF 파일 확인
diff --git a/backend/src/api/routes/highlights.py b/backend/src/api/routes/highlights.py
index 11db165..9c66d0b 100644
--- a/backend/src/api/routes/highlights.py
+++ b/backend/src/api/routes/highlights.py
@@ -84,8 +84,8 @@ async def create_highlight(
detail="Document not found"
)
- # 문서 접근 권한 확인
- if not document.is_public and document.uploaded_by != current_user.id and not current_user.is_admin:
+ # 문서 접근 권한 확인 (관리자 또는 문서 관리 권한이 있으면 모든 문서 접근 가능)
+ if not (current_user.is_admin or current_user.can_manage_books) and not document.is_public and document.uploaded_by != current_user.id:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Not enough permissions to access this document"
diff --git a/frontend/components/header.html b/frontend/components/header.html
index 5fe279f..58309c1 100644
--- a/frontend/components/header.html
+++ b/frontend/components/header.html
@@ -213,7 +213,7 @@