Преглед на файлове

Add Authorization checks (#2235)

### What problem does this PR solve?

Add Authorization checks

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

Co-authored-by: Feiue <10215101452@stu.ecun.edu.cn>
tags/v0.11.0
LiuHua преди 1 година
родител
ревизия
65255f2a8e
No account linked to committer's email address
променени са 1 файла, в които са добавени 12 реда и са изтрити 1 реда
  1. 12
    1
      api/apps/canvas_app.py

+ 12
- 1
api/apps/canvas_app.py Целия файл

@@ -68,8 +68,11 @@ def save():
if not UserCanvasService.save(**req):
return get_data_error_result(retmsg="Fail to save canvas.")
else:
if not UserCanvasService.query(user_id=current_user.id, id=req["id"]):
return get_json_result(
data=False, retmsg=f'Only owner of canvas authorized for this operation.',
retcode=RetCode.OPERATING_ERROR)
UserCanvasService.update_by_id(req["id"], req)

return get_json_result(data=req)


@@ -91,6 +94,10 @@ def run():
e, cvs = UserCanvasService.get_by_id(req["id"])
if not e:
return get_data_error_result(retmsg="canvas not found.")
if not UserCanvasService.query(user_id=current_user.id, id=req["id"]):
return get_json_result(
data=False, retmsg=f'Only owner of canvas authorized for this operation.',
retcode=RetCode.OPERATING_ERROR)

if not isinstance(cvs.dsl, str):
cvs.dsl = json.dumps(cvs.dsl, ensure_ascii=False)
@@ -157,6 +164,10 @@ def reset():
e, user_canvas = UserCanvasService.get_by_id(req["id"])
if not e:
return get_data_error_result(retmsg="canvas not found.")
if not UserCanvasService.query(user_id=current_user.id, id=req["id"]):
return get_json_result(
data=False, retmsg=f'Only owner of canvas authorized for this operation.',
retcode=RetCode.OPERATING_ERROR)

canvas = Canvas(json.dumps(user_canvas.dsl), current_user.id)
canvas.reset()

Loading…
Отказ
Запис