mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(test): Fixes for "TestClient" changes
Seems that client is optional according to the ASGI spec. https://asgi.readthedocs.io/en/latest/specs/www.html With Starlette 0.35 the TestClient connection scope is None for "client". https://github.com/encode/starlette/pull/2377 Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
parent
22e1577324
commit
2fcd793a58
8 changed files with 29 additions and 16 deletions
|
@ -2,6 +2,7 @@ from fastapi import Request
|
|||
|
||||
from aurweb import db, schema
|
||||
from aurweb.models.declarative import Base
|
||||
from aurweb.util import get_client_ip
|
||||
|
||||
|
||||
class Ban(Base):
|
||||
|
@ -14,6 +15,6 @@ class Ban(Base):
|
|||
|
||||
|
||||
def is_banned(request: Request):
|
||||
ip = request.client.host
|
||||
ip = get_client_ip(request)
|
||||
exists = db.query(Ban).filter(Ban.IPAddress == ip).exists()
|
||||
return db.query(exists).scalar()
|
||||
|
|
|
@ -122,7 +122,7 @@ class User(Base):
|
|||
try:
|
||||
with db.begin():
|
||||
self.LastLogin = now_ts
|
||||
self.LastLoginIPAddress = request.client.host
|
||||
self.LastLoginIPAddress = util.get_client_ip(request)
|
||||
if not self.session:
|
||||
sid = generate_unique_sid()
|
||||
self.session = db.create(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue