-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
boilerplate for /users/me/groups and projects
- Loading branch information
1 parent
ac13307
commit eefb3f4
Showing
6 changed files
with
73 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,49 @@ | ||
from fastapi import APIRouter, Depends | ||
|
||
from .dependencies import get_authenticated_user, retrieve_subjects | ||
from .schemas import SubjectList, User | ||
from .dependencies import ( | ||
get_authenticated_user, | ||
retrieve_groups, | ||
retrieve_projects, | ||
retrieve_subjects, | ||
) | ||
from .schemas import User, UserGroupList, UserProjectList, UserSubjectList | ||
|
||
router = APIRouter( | ||
prefix="/api/users", tags=["user"], responses={404: {"description": "Not Found"}} | ||
) | ||
|
||
|
||
@router.get("/me") | ||
async def profile(user=Depends(get_authenticated_user)) -> User: | ||
async def profile(user: User = Depends(get_authenticated_user)) -> User: | ||
""" | ||
Get information about the current user | ||
""" | ||
return user | ||
|
||
|
||
@router.get("/me/subjects") | ||
async def subjects(subjects: SubjectList = Depends(retrieve_subjects)) -> SubjectList: | ||
async def subjects( | ||
subjects: UserSubjectList = Depends(retrieve_subjects), | ||
) -> UserSubjectList: | ||
""" | ||
Get the subjects of the current user | ||
""" | ||
return subjects | ||
|
||
|
||
@router.get("/me/groups") | ||
async def groups(groups: UserGroupList = Depends(retrieve_groups)) -> UserGroupList: | ||
""" | ||
Get the groups of the current user | ||
""" | ||
return groups | ||
|
||
|
||
@router.get("/me/projects") | ||
async def projects( | ||
projects: UserProjectList = Depends(retrieve_projects), | ||
) -> UserProjectList: | ||
""" | ||
Get the projects of the current user | ||
""" | ||
return projects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters