Skip to content

Commit

Permalink
Extract user endpoints (#3547)
Browse files Browse the repository at this point in the history
  • Loading branch information
seallard authored Aug 19, 2024
1 parent 5ffbb07 commit 848e525
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions cg/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from flask_dance.contrib.google import google, make_google_blueprint
from sqlalchemy.orm import scoped_session

from cg.server import admin, api, ext, invoices
from cg.server import admin, ext, invoices
from cg.server.app_config import app_config
from cg.server.endpoints.analyses import ANALYSES_BLUEPRINT
from cg.server.endpoints.flow_cells import FLOW_CELLS_BLUEPRINT
Expand All @@ -15,6 +15,7 @@
from cg.server.endpoints.cases import CASES_BLUEPRINT
from cg.server.endpoints.pools import POOLS_BLUEPRINT
from cg.server.endpoints.samples import SAMPLES_BLUEPRINT
from cg.server.endpoints.users import USERS_BLUEPRINT
from cg.store.database import get_scoped_session_registry
from cg.store.models import (
Analysis,
Expand Down Expand Up @@ -90,7 +91,6 @@ def logged_in(blueprint, token):
user_data = resp.json()
session["user_email"] = user_data["email"]

app.register_blueprint(api.BLUEPRINT)
app.register_blueprint(invoices.BLUEPRINT, url_prefix="/invoices")
app.register_blueprint(oauth_bp, url_prefix="/login")
app.register_blueprint(APPLICATIONS_BLUEPRINT)
Expand All @@ -100,17 +100,16 @@ def logged_in(blueprint, token):
app.register_blueprint(POOLS_BLUEPRINT)
app.register_blueprint(FLOW_CELLS_BLUEPRINT)
app.register_blueprint(ANALYSES_BLUEPRINT)

_register_admin_views()

ext.csrf.exempt(api.BLUEPRINT)
ext.csrf.exempt(SAMPLES_BLUEPRINT)
ext.csrf.exempt(CASES_BLUEPRINT)
ext.csrf.exempt(APPLICATIONS_BLUEPRINT)
ext.csrf.exempt(ORDERS_BLUEPRINT)
ext.csrf.exempt(POOLS_BLUEPRINT)
ext.csrf.exempt(FLOW_CELLS_BLUEPRINT)
ext.csrf.exempt(ANALYSES_BLUEPRINT)
ext.csrf.exempt(USERS_BLUEPRINT)

@app.route("/")
def index():
Expand Down
6 changes: 3 additions & 3 deletions cg/server/api.py → cg/server/endpoints/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from cg.server.endpoints.utils import before_request

LOG = logging.getLogger(__name__)
BLUEPRINT = Blueprint("api", __name__, url_prefix="/api/v1")
BLUEPRINT.before_request(before_request)
USERS_BLUEPRINT = Blueprint("users", __name__, url_prefix="/api/v1")
USERS_BLUEPRINT.before_request(before_request)


@BLUEPRINT.route("/me")
@USERS_BLUEPRINT.route("/me")
def get_user_information():
"""Return information about current user."""
if not g.current_user.is_admin and not g.current_user.customers:
Expand Down

0 comments on commit 848e525

Please sign in to comment.