Preserve broker link on token expiry
This commit is contained in:
parent
f92b5c5afc
commit
1a7466728a
@ -136,6 +136,20 @@ def clear_user_broker(user_id: str):
|
|||||||
cur.execute("DELETE FROM user_broker WHERE user_id = %s", (user_id,))
|
cur.execute("DELETE FROM user_broker WHERE user_id = %s", (user_id,))
|
||||||
|
|
||||||
|
|
||||||
|
def expire_user_broker_session(user_id: str):
|
||||||
|
with db_transaction() as cur:
|
||||||
|
cur.execute(
|
||||||
|
"""
|
||||||
|
UPDATE user_broker
|
||||||
|
SET connected = TRUE,
|
||||||
|
access_token = NULL,
|
||||||
|
auth_state = 'EXPIRED'
|
||||||
|
WHERE user_id = %s
|
||||||
|
""",
|
||||||
|
(user_id,),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def set_pending_broker(user_id: str, broker: str, api_key: str, api_secret: str):
|
def set_pending_broker(user_id: str, broker: str, api_key: str, api_secret: str):
|
||||||
started_at = now_utc()
|
started_at = now_utc()
|
||||||
with db_transaction() as cur:
|
with db_transaction() as cur:
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from datetime import datetime, timedelta
|
|||||||
from fastapi import APIRouter, HTTPException, Query, Request
|
from fastapi import APIRouter, HTTPException, Query, Request
|
||||||
from fastapi.responses import HTMLResponse
|
from fastapi.responses import HTMLResponse
|
||||||
|
|
||||||
from app.broker_store import clear_user_broker
|
from app.broker_store import expire_user_broker_session
|
||||||
from app.services.auth_service import get_user_for_session
|
from app.services.auth_service import get_user_for_session
|
||||||
from app.services.live_equity_service import (
|
from app.services.live_equity_service import (
|
||||||
capture_live_equity_snapshot,
|
capture_live_equity_snapshot,
|
||||||
@ -49,7 +49,7 @@ def _capture_request_token(request: Request, request_token: str):
|
|||||||
|
|
||||||
|
|
||||||
def _clear_broker_session(user_id: str):
|
def _clear_broker_session(user_id: str):
|
||||||
clear_user_broker(user_id)
|
expire_user_broker_session(user_id)
|
||||||
clear_session(user_id)
|
clear_session(user_id)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user