Spaces:
Sleeping
Sleeping
Update components/middleware.py
Browse files- components/middleware.py +30 -2
components/middleware.py
CHANGED
|
@@ -23,7 +23,15 @@ import time
|
|
| 23 |
|
| 24 |
from geopy.geocoders import Nominatim
|
| 25 |
from geopy.exc import GeocoderServiceError
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
geolocator = Nominatim(user_agent="velocity")
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
|
|
@@ -332,10 +340,22 @@ class x401Kit(BaseHTTPMiddleware):
|
|
| 332 |
|
| 333 |
signverify=SignatureVerification(X_401_Addr,X_401_Nonce,X_401_Sign,challange)
|
| 334 |
tokenverify=TokenCheck(X_401_Addr,required_mint,mint_amount)
|
|
|
|
| 335 |
print(tokenverify)
|
| 336 |
|
| 337 |
|
| 338 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
|
| 340 |
if signverify == True and tokenverify == True:
|
| 341 |
|
|
@@ -344,6 +364,7 @@ class x401Kit(BaseHTTPMiddleware):
|
|
| 344 |
|
| 345 |
country=GEOCODER(coords)
|
| 346 |
print(country)
|
|
|
|
| 347 |
|
| 348 |
if country["data"] is None:
|
| 349 |
return JSONResponse(
|
|
@@ -367,7 +388,14 @@ class x401Kit(BaseHTTPMiddleware):
|
|
| 367 |
},
|
| 368 |
status_code=401
|
| 369 |
)
|
| 370 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
|
| 372 |
response = await call_next(request)
|
| 373 |
|
|
|
|
| 23 |
|
| 24 |
from geopy.geocoders import Nominatim
|
| 25 |
from geopy.exc import GeocoderServiceError
|
| 26 |
+
from .mongodbconnection import provideClient
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
geolocator = Nominatim(user_agent="velocity")
|
| 32 |
+
dbclient=provideClient()
|
| 33 |
+
db=dbclient["sdklogs_db"]
|
| 34 |
+
col=dbclient["sdklogs_col"]
|
| 35 |
|
| 36 |
|
| 37 |
|
|
|
|
| 340 |
|
| 341 |
signverify=SignatureVerification(X_401_Addr,X_401_Nonce,X_401_Sign,challange)
|
| 342 |
tokenverify=TokenCheck(X_401_Addr,required_mint,mint_amount)
|
| 343 |
+
|
| 344 |
print(tokenverify)
|
| 345 |
|
| 346 |
|
| 347 |
+
sdkpayload={
|
| 348 |
+
|
| 349 |
+
"signer":X_401_Addr,
|
| 350 |
+
"challange":challange,
|
| 351 |
+
"token_amount":mint_amount,
|
| 352 |
+
"required_mint":required_mint,
|
| 353 |
+
"sign_verification":signverify,
|
| 354 |
+
"token_verification":tokenverify,
|
| 355 |
+
"geo_code":geo_code,
|
| 356 |
+
"restricted_loc":geo_code_locs
|
| 357 |
+
|
| 358 |
+
}
|
| 359 |
|
| 360 |
if signverify == True and tokenverify == True:
|
| 361 |
|
|
|
|
| 364 |
|
| 365 |
country=GEOCODER(coords)
|
| 366 |
print(country)
|
| 367 |
+
sdkpayload["geography"]=country
|
| 368 |
|
| 369 |
if country["data"] is None:
|
| 370 |
return JSONResponse(
|
|
|
|
| 388 |
},
|
| 389 |
status_code=401
|
| 390 |
)
|
| 391 |
+
|
| 392 |
+
coll.find_one_and_update(
|
| 393 |
+
{"owner":"system"},
|
| 394 |
+
{
|
| 395 |
+
"$push":{
|
| 396 |
+
"logs":sdkpayload
|
| 397 |
+
}
|
| 398 |
+
})
|
| 399 |
|
| 400 |
response = await call_next(request)
|
| 401 |
|