Skip to content

Commit

Permalink
changed scope name
Browse files Browse the repository at this point in the history
  • Loading branch information
zipperman1 committed Nov 24, 2024
1 parent e174ee4 commit 5a3d43c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rating_api/routes/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
@comment.post("", response_model=CommentGet)
async def create_comment(lecturer_id: int, comment_info: CommentPost, user=Depends(UnionAuth())) -> CommentGet:
"""
Scopes: `["rating.comment.create"]`
Scopes: `["rating.comment.import"]`
Создает комментарий к преподавателю в базе данных RatingAPI
Для создания комментария нужно быть авторизованным
Для возможности создания комментария с указанием времени создания и изменения необходим скоуп ["rating.comment.create"]
Для возможности создания комментария с указанием времени создания и изменения необходим скоуп ["rating.comment.import"]
"""
lecturer = Lecturer.get(session=db.session, id=lecturer_id)
if not lecturer:
raise ObjectNotFound(Lecturer, lecturer_id)

has_create_scope = "rating.comment.create" in [scope['name'] for scope in user.get('session_scopes')]
has_create_scope = "rating.comment.import" in [scope['name'] for scope in user.get('session_scopes')]
if (comment_info.create_ts or comment_info.update_ts) and not has_create_scope:
raise ForbiddenAction(Comment)

Expand Down

0 comments on commit 5a3d43c

Please sign in to comment.