Skip to content

Commit

Permalink
add auth
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydzhou committed Dec 29, 2023
1 parent 726b751 commit c91dafe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/routes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .github import *
from .lark import *
from .team import *
20 changes: 20 additions & 0 deletions server/routes/team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import logging

from app import app
from flask import Blueprint, abort, jsonify, redirect, request
from utils.auth import authenticated

bp = Blueprint("team", __name__, url_prefix="/api/team")


@bp.route("/", methods=["GET"])
@authenticated
def get_team_list():
"""
get team list
TODO
"""
return jsonify({"code": 0, "msg": "success", "data": [], "total": 0})


app.register_blueprint(bp)
13 changes: 13 additions & 0 deletions server/utils/auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from functools import wraps

from flask import abort, session


def authenticated(func):
@wraps(func)
def wrapper(*args, **kwargs):
if "user_id" not in session:
return abort(401)
return func(*args, **kwargs)

return wrapper

0 comments on commit c91dafe

Please sign in to comment.