Spaces:
Sleeping
Sleeping
Update components/middleware.py
Browse files- components/middleware.py +29 -1
components/middleware.py
CHANGED
|
@@ -11,8 +11,14 @@ import json
|
|
| 11 |
import httpx
|
| 12 |
from geopy.geocoders import Nominatim
|
| 13 |
from geopy.exc import GeocoderServiceError
|
|
|
|
|
|
|
| 14 |
geolocator = Nominatim(user_agent="velocity")
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
|
|
@@ -233,6 +239,20 @@ class x401Kit(BaseHTTPMiddleware):
|
|
| 233 |
tokenverify=TokenCheck(X_401_Addr)
|
| 234 |
print(tokenverify)
|
| 235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
if signverify == True and tokenverify == True:
|
| 237 |
|
| 238 |
|
|
@@ -240,6 +260,7 @@ class x401Kit(BaseHTTPMiddleware):
|
|
| 240 |
|
| 241 |
country=GEOCODER(coords)
|
| 242 |
print(country)
|
|
|
|
| 243 |
|
| 244 |
if country["data"] is None:
|
| 245 |
return JSONResponse(
|
|
@@ -263,7 +284,14 @@ class x401Kit(BaseHTTPMiddleware):
|
|
| 263 |
},
|
| 264 |
status_code=401
|
| 265 |
)
|
| 266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
|
| 268 |
response = await call_next(request)
|
| 269 |
|
|
|
|
| 11 |
import httpx
|
| 12 |
from geopy.geocoders import Nominatim
|
| 13 |
from geopy.exc import GeocoderServiceError
|
| 14 |
+
from .mongodbconnection import provideClient
|
| 15 |
+
|
| 16 |
geolocator = Nominatim(user_agent="velocity")
|
| 17 |
|
| 18 |
+
dbclient=provideClient()
|
| 19 |
+
db=dbclient["sdklogs_db"]
|
| 20 |
+
coll=dbclient["sdklogs_col"]
|
| 21 |
+
|
| 22 |
|
| 23 |
|
| 24 |
|
|
|
|
| 239 |
tokenverify=TokenCheck(X_401_Addr)
|
| 240 |
print(tokenverify)
|
| 241 |
|
| 242 |
+
|
| 243 |
+
sdkpayload={
|
| 244 |
+
|
| 245 |
+
"signer":X_401_Addr,
|
| 246 |
+
"challange":challange,
|
| 247 |
+
"token_amount":mint_amount,
|
| 248 |
+
"required_mint":required_mint,
|
| 249 |
+
"sign_verification":signverify,
|
| 250 |
+
"token_verification":tokenverify,
|
| 251 |
+
"geo_code":geo_code,
|
| 252 |
+
"restricted_loc":geo_code_locs
|
| 253 |
+
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
if signverify == True and tokenverify == True:
|
| 257 |
|
| 258 |
|
|
|
|
| 260 |
|
| 261 |
country=GEOCODER(coords)
|
| 262 |
print(country)
|
| 263 |
+
sdkpayload["geography"]=country
|
| 264 |
|
| 265 |
if country["data"] is None:
|
| 266 |
return JSONResponse(
|
|
|
|
| 284 |
},
|
| 285 |
status_code=401
|
| 286 |
)
|
| 287 |
+
|
| 288 |
+
coll.find_one_and_update(
|
| 289 |
+
{"owner":"system"},
|
| 290 |
+
{
|
| 291 |
+
"$push":{
|
| 292 |
+
"logs":sdkpayload
|
| 293 |
+
}
|
| 294 |
+
})
|
| 295 |
|
| 296 |
response = await call_next(request)
|
| 297 |
|