Skip to content

Commit

Permalink
ADDED: authorization on investement risk analyst agent
Browse files Browse the repository at this point in the history
  • Loading branch information
AquibPy committed Jun 25, 2024
1 parent e1f5b66 commit 4d83b42
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion api.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,19 @@ async def process_video(request: Request, video_url: str = Form(...)):
@limiter.limit("2/30minute")
async def run_risk_investment_agent(request:Request,stock_selection: str = Form("AAPL"),
risk_tolerance : str = Form("Medium"),
trading_strategy_preference: str = Form("Day Trading")):
trading_strategy_preference: str = Form("Day Trading"),
token: str = Depends(oauth2_scheme)):
try:
payload = jwt.decode(token, os.getenv("TOKEN_SECRET_KEY"), algorithms=[settings.ALGORITHM])
email = payload.get("sub")
if email is None:
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")
user = users_collection.find_one({"email": email})
if user is None:
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="User not found")
except JWTError:
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")

try:
input_data = {"stock_selection": stock_selection,
"risk_tolerance": risk_tolerance,
Expand Down

0 comments on commit 4d83b42

Please sign in to comment.