|
18 | 18 | ) |
19 | 19 | from core.formatting import _str_to_bool |
20 | 20 | from database.users import User |
21 | | -from routers.dependencies import expdb_connection, fetch_user |
| 21 | +from routers.dependencies import expdb_connection, fetch_user, fetch_user_or_raise |
22 | 22 | from schemas.core import Visibility |
23 | 23 | from schemas.study import CreateStudy, Study, StudyStatus, StudyType |
24 | 24 |
|
@@ -62,7 +62,7 @@ class AttachDetachResponse(BaseModel): |
62 | 62 | async def attach_to_study( |
63 | 63 | study_id: Annotated[int, Body()], |
64 | 64 | entity_ids: Annotated[list[int], Body()], |
65 | | - user: Annotated[User | None, Depends(fetch_user)] = None, |
| 65 | + user: Annotated[User, Depends(fetch_user_or_raise)], |
66 | 66 | expdb: Annotated[AsyncConnection, Depends(expdb_connection)] = None, |
67 | 67 | ) -> AttachDetachResponse: |
68 | 68 | assert expdb is not None # noqa: S101 |
@@ -99,13 +99,10 @@ async def attach_to_study( |
99 | 99 | @router.post("/") |
100 | 100 | async def create_study( |
101 | 101 | study: CreateStudy, |
102 | | - user: Annotated[User | None, Depends(fetch_user)] = None, |
| 102 | + user: Annotated[User, Depends(fetch_user_or_raise)], |
103 | 103 | expdb: Annotated[AsyncConnection, Depends(expdb_connection)] = None, |
104 | 104 | ) -> dict[Literal["study_id"], int]: |
105 | 105 | assert expdb is not None # noqa: S101 |
106 | | - if user is None: |
107 | | - msg = "Creating a study requires authentication." |
108 | | - raise AuthenticationRequiredError(msg) |
109 | 106 | if study.main_entity_type == StudyType.RUN and study.tasks: |
110 | 107 | msg = "Cannot create a run study with tasks." |
111 | 108 | raise StudyInvalidTypeError(msg) |
|
0 commit comments