Skip to content

Commit

Permalink
fix:add a shortcut for authing in development mode without openid
Browse files Browse the repository at this point in the history
  • Loading branch information
zqi-wong committed Oct 22, 2021
1 parent 6bfa431 commit ff9d4bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/pkuphysu_wechat/api/random_draw/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def join():
@bp.route("/all", methods=["GET"])
def get_all():
openid = token_required()
if openid not in settings.wechat.MASTER_IDS:
if openid not in settings.WECHAT.MASTER_IDS and not (
openid == "developmentopenid" and not settings.PRODUCTION
):
abort(404)
return respond_success(data=[record.name for record in RandomDraw.query.all()])
4 changes: 3 additions & 1 deletion src/pkuphysu_wechat/auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def token_required() -> str:

def master_required():
openid = token_required()
if openid not in settings.WECHAT.MASTER_IDS:
if openid not in settings.WECHAT.MASTER_IDS and not (
openid == "developmentopenid" and not settings.PRODUCTION
):
logger.info("%s tried to access admin resouces", openid)
abort(respond_error(403, "NoHackMaster"))

Expand Down

0 comments on commit ff9d4bc

Please sign in to comment.