Extract httpBasic from function header

This commit is contained in:
Matthias 2024-04-20 10:10:57 +02:00
parent 927c54094a
commit 08f2eebd6e
2 changed files with 5 additions and 2 deletions

View File

@ -26,6 +26,7 @@ def verify_auth(api_config, username: str, password: str):
httpbasic = HTTPBasic(auto_error=False) httpbasic = HTTPBasic(auto_error=False)
security = HTTPBasic()
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token", auto_error=False) oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token", auto_error=False)
@ -117,7 +118,7 @@ def http_basic_or_jwt_token(form_data: HTTPBasicCredentials = Depends(httpbasic)
@router_login.post('/token/login', response_model=AccessAndRefreshToken) @router_login.post('/token/login', response_model=AccessAndRefreshToken)
def token_login(form_data: HTTPBasicCredentials = Depends(HTTPBasic()), def token_login(form_data: HTTPBasicCredentials = Depends(security),
api_config=Depends(get_api_config)): api_config=Depends(get_api_config)):
if verify_auth(api_config, form_data.username, form_data.password): if verify_auth(api_config, form_data.username, form_data.password):

View File

@ -460,8 +460,10 @@ class RPC:
def _rpc_trade_statistics( def _rpc_trade_statistics(
self, stake_currency: str, fiat_display_currency: str, self, stake_currency: str, fiat_display_currency: str,
start_date: datetime = datetime.fromtimestamp(0)) -> Dict[str, Any]: start_date: Optional[datetime] = None) -> Dict[str, Any]:
""" Returns cumulative profit statistics """ """ Returns cumulative profit statistics """
if start_date is None:
start_date = datetime.fromtimestamp(0)
trade_filter = ((Trade.is_open.is_(False) & (Trade.close_date >= start_date)) | trade_filter = ((Trade.is_open.is_(False) & (Trade.close_date >= start_date)) |
Trade.is_open.is_(True)) Trade.is_open.is_(True))
trades: Sequence[Trade] = Trade.session.scalars(Trade.get_trades_query( trades: Sequence[Trade] = Trade.session.scalars(Trade.get_trades_query(