Resetting utils subtree.
This commit is contained in:
@@ -94,25 +94,28 @@ class SMSAuthModel(BaseModel):
|
||||
|
||||
AUTH_COLLECTION = "_authTokens"
|
||||
|
||||
async def set_token(
|
||||
async def set(
|
||||
self,
|
||||
db_conn: AsyncMySQL,
|
||||
mongo_conn: AsyncMongo,
|
||||
user_info: dict,
|
||||
client_user_id: dict,
|
||||
auth: dict,
|
||||
token: dict,
|
||||
service_client: Literal["nimbusSmsIndia", "savvyBulkSmsKenya"],
|
||||
auth_type: Literal["auth"],
|
||||
sync_freq: Literal[60, 300, 900] = 300,
|
||||
session_token: str = None
|
||||
) -> ObjectId:
|
||||
) -> ObjectId | None:
|
||||
|
||||
"""
|
||||
Stores params from the session info and gives an identifier to use in the authorization URL. Use this when the
|
||||
user requests an authorization URL to link your service to another service (like GMail).
|
||||
To store auth/tokens for a particular service to the database.
|
||||
:param db_conn: The database connection (MariaDB) to use to perform the action.
|
||||
:param mongo_conn: The database connection (MongoDB) to use to perform the action.
|
||||
:param user_info: The dictionary that has the user's session information.
|
||||
:param client_user_id: The way the third-party client recognizes your user.
|
||||
:param auth: The authentication details of the account.
|
||||
:param token: The token granted by the third-party service.
|
||||
:param service_client: The name of the company or brand that is providing this service that is being integrated.
|
||||
:param auth_type: To identify the type of authentication being done here. This could indicate simple password
|
||||
authentication, more advance OAuth2.0 authentication, etc.
|
||||
@@ -137,21 +140,22 @@ class SMSAuthModel(BaseModel):
|
||||
}),
|
||||
update = {
|
||||
"$set": {
|
||||
"lastRequestTs": request_ts
|
||||
"lastRequestTs": request_ts,
|
||||
"status": "active",
|
||||
"syncFreq": max(sync_freq, 60)
|
||||
},
|
||||
"$setOnInsert": {
|
||||
"version": "1.1.1",
|
||||
"serviceType": "email",
|
||||
"version": "1.0.0",
|
||||
"serviceType": "sms",
|
||||
"client": service_client,
|
||||
"authType": auth_type,
|
||||
"user": user_info,
|
||||
"clientUserId": client_user_id,
|
||||
"token": None,
|
||||
"auth": auth,
|
||||
"token": token,
|
||||
"firstRefreshTs": None,
|
||||
"lastRefreshTs": None,
|
||||
"firstRequestTs": request_ts,
|
||||
"status": "active",
|
||||
"syncFreq": max(sync_freq, 60)
|
||||
"firstRequestTs": request_ts
|
||||
}
|
||||
},
|
||||
projection = {
|
||||
@@ -168,15 +172,15 @@ class SMSAuthModel(BaseModel):
|
||||
db_conn = db_conn,
|
||||
proc_name = "entity_integration_save",
|
||||
proc_args = (
|
||||
user_info["entityId"], # ............................................ 'p_entity_id'
|
||||
service_client, # ................................................... 'p_provider'
|
||||
"Auth Requested", # ................................................. 'p_current_status'
|
||||
"Auth URL Generated", # ............................................. 'p_last_action'
|
||||
None, # ............................................................. 'p_display_name'
|
||||
None, # ............................................................. 'p_display_picture'
|
||||
str(mongo_json["_id"]), # ........................................... 'p_token_id'
|
||||
json.to_string(python_data = {"email": None}, no_space = True), # ... 'p_notes'
|
||||
user_info["userId"] # ............................................... 'p_created_by'
|
||||
user_info["entityId"], # ........................................... 'p_entity_id'
|
||||
service_client, # .................................................. 'p_provider'
|
||||
"Active", # ........................................................ 'p_current_status'
|
||||
"Auth Details Accepted", # ......................................... 'p_last_action'
|
||||
None, # ............................................................ 'p_display_name'
|
||||
None, # ............................................................ 'p_display_picture'
|
||||
str(mongo_json["_id"]), # .......................................... 'p_token_id'
|
||||
json.to_string(python_data = client_user_id, no_space = True), # ... 'p_notes'
|
||||
user_info["userId"] # .............................................. 'p_created_by'
|
||||
),
|
||||
session_token = session_token
|
||||
)
|
||||
@@ -184,7 +188,7 @@ class SMSAuthModel(BaseModel):
|
||||
# Done here:
|
||||
return mongo_json["_id"] if mongo_json and db_json.get("status") == 1 else None
|
||||
|
||||
async def get_token(
|
||||
async def get(
|
||||
self,
|
||||
mongo_conn: AsyncMongo,
|
||||
token_id: ObjectId | str = None,
|
||||
@@ -192,7 +196,7 @@ class SMSAuthModel(BaseModel):
|
||||
) -> dict | None:
|
||||
|
||||
"""
|
||||
To retrieve stored tokens from the database.
|
||||
To retrieve stored auth/tokens from the database.
|
||||
:param mongo_conn: The database connection (MongoDB) to use to perform the action.
|
||||
:param token_id: The identifier granted providing auth details for the first time in 'set_token'.
|
||||
:param kwargs: Any set of key-value pairs to build custom search criteria. This could be things like the user
|
||||
|
||||
Reference in New Issue
Block a user