|
26 | 26 |
|
27 | 27 | # Import routes
|
28 | 28 | from app.routes import admin, api, infra, stripe, wallet
|
| 29 | + |
| 30 | +# This check is a little hacky and needs to be documented in the dev environment set up |
| 31 | +# If it's run under docker, the -e flag should set the env variable, but if its local you have to set it yourself |
| 32 | +# Use 'export ENV=development' to set the env variable |
| 33 | +if os.getenv("ENV") == "development": |
| 34 | + from app.routes import dev_auth |
29 | 35 | from app.util.approve import Approve
|
30 | 36 |
|
31 | 37 | # Import middleware
|
@@ -95,6 +101,14 @@ def global_context(request: Request):
|
95 | 101 | app.include_router(wallet.router)
|
96 | 102 | app.include_router(infra.router)
|
97 | 103 |
|
| 104 | +# This check is a little hacky and needs to be documented in the dev environment set up |
| 105 | +# If it's run under docker, the -e flag should set the env variable, but if its local you have to set it yourself |
| 106 | +# Use 'export ENV=development' to set the env variable |
| 107 | +if os.getenv("ENV") == "development": |
| 108 | + logger.warning("loading dev endpoints") |
| 109 | + app.include_router(dev_auth.router) |
| 110 | + |
| 111 | + |
98 | 112 | # TODO figure out wtf this is used for
|
99 | 113 | # Create the OpenStack SDK config.
|
100 | 114 | # with open("clouds.yaml", "w", encoding="utf-8") as f:
|
@@ -398,53 +412,3 @@ async def logout(request: Request):
|
398 | 412 | @app.get("/favicon.ico", include_in_schema=False)
|
399 | 413 | async def favicon():
|
400 | 414 | return FileResponse("./app/static/favicon.ico")
|
401 |
| - |
402 |
| - |
403 |
| -# This check is a little hacky and needs to be documented in the dev environment set up |
404 |
| -# If it's run under docker, the -e flag should set the env variable, but if its local you have to set it yourself |
405 |
| -# Use 'export ENV=development' to set the env variable |
406 |
| -if os.getenv("ENV") == "development": |
407 |
| - |
408 |
| - @app.get("/dev/user") |
409 |
| - async def create_dev_user(request: Request, session: Session = Depends(get_session)): |
410 |
| - if request.client.host not in ["127.0.0.1", "localhost"]: |
411 |
| - return Errors.generate( |
412 |
| - request, |
413 |
| - 403, |
414 |
| - "Forbidden", |
415 |
| - essay="This endpoint is only available on localhost.", |
416 |
| - ) |
417 |
| - |
418 |
| - # Generate random user data |
419 |
| - user_id = uuid.uuid4() |
420 |
| - discord_id = str(uuid.uuid4()) |
421 |
| - |
422 |
| - user = UserModel( |
423 |
| - id=user_id, |
424 |
| - discord_id=discord_id, |
425 |
| - ) |
426 |
| - |
427 |
| - discord_user = DiscordModel(username=f"devuser-{user_id}", email=f"devuser@mail.com", user_id=user_id, user=user) |
428 |
| - |
429 |
| - session.add(user) |
430 |
| - session.commit() |
431 |
| - session.refresh(user) |
432 |
| - |
433 |
| - session.add(discord_user) |
434 |
| - session.commit() |
435 |
| - session.refresh(discord_user) |
436 |
| - |
437 |
| - # Create JWT token for the user |
438 |
| - bearer = Authentication.create_jwt(user) |
439 |
| - rr = RedirectResponse("/profile", status_code=status.HTTP_302_FOUND) |
440 |
| - max_age = Settings().jwt.lifetime_sudo |
441 |
| - rr.set_cookie( |
442 |
| - key="token", |
443 |
| - value=bearer, |
444 |
| - httponly=True, |
445 |
| - samesite="lax", |
446 |
| - secure=False, |
447 |
| - max_age=max_age, |
448 |
| - ) |
449 |
| - |
450 |
| - return rr |
0 commit comments