refactor(backend): ♻️ change error messages to follow standard pattern to match locals on frontend (#668)

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden
2021-09-02 21:33:18 -08:00
committed by GitHub
parent abc0d0d59f
commit b550dae593
11 changed files with 415 additions and 72 deletions

View File

@@ -3,12 +3,12 @@ from sqlalchemy.orm.session import Session
from mealie.schema.user.user import PrivateUser
from .dependencies import generate_session, get_current_user, is_logged_in
from .dependencies import generate_session, get_admin_user, get_current_user, is_logged_in
class ReadDeps:
class PublicDeps:
"""
ReadDeps contains the common dependencies for all read operations through the API.
PublicDeps contains the common dependencies for all read operations through the API.
Note: The user object is used to definer what assets the user has access to.
Args:
@@ -28,9 +28,9 @@ class ReadDeps:
self.user: bool = user
class WriteDeps:
class UserDeps:
"""
WriteDeps contains the common dependencies for all read operations through the API.
UserDeps contains the common dependencies for all read operations through the API.
Note: The user must be logged in or the route will return a 401 error.
Args:
@@ -48,3 +48,15 @@ class WriteDeps:
self.session: Session = session
self.bg_task: BackgroundTasks = background_tasks
self.user: PrivateUser = user
class AdminDeps:
def __init__(
self,
background_tasks: BackgroundTasks,
session: Session = Depends(generate_session),
user=Depends(get_admin_user),
):
self.session: Session = session
self.bg_task: BackgroundTasks = background_tasks
self.user: PrivateUser = user