Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subscribe API for COSCUP-Volunteer and API Token management page #7

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

orertrr
Copy link
Member

@orertrr orertrr commented Jul 16, 2024

Pull request type

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

Related Issue

What is the new behavior?

  • 新增 API Token 管理介面
  • 新增 API 以新增訂閱者

Other Informations

新增訂閱者 API

image

API Token management page

image

@orertrr orertrr requested a review from toomore July 16, 2024 05:40
Copy link
Member

@toomore toomore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orertrr 先修正關於排序的問題,還有搬移到 API endpoint 中,其他的我再繼續看,怕我卡住太久!

Comment on lines +68 to +77
if request.path.startswith('/volunteer'):
token = request.headers.get('Authorization')
if token is None:
return make_response('Unauthorized', 401)

if APIToken.verify(token) is True:
return None

return make_response('Unauthorized', 401)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orertrr 這段移到 view/volunteer.py 的每一個 endpoint 去判斷,這裡想要單純的扮演 route 的節點。然後在 Line 78 加入 and not request.path.startswith('/volunteer')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這部分如果包成 function 然後掛一個 VIEW_VOLUNTEER.before_request 的 decorator 上去可以嗎?

理論上這樣寫可以有同樣的效果,且之後 /volunteer 底下有要再加 Endpoint 時也不用再寫同樣的邏輯

models/index.py Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這個檔案上方 import 好像沒有排序,APITokenDB().index() 應該可以移上去 Line 7。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修正

main.py Outdated
Comment on lines 44 to 45
app.register_blueprint(VIEW_VOLUNTEER)
app.register_blueprint(VIEW_TOKEN)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 39 - Line 45 這裡排序一下。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修正

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants