This commit is contained in:
Kenneth Kehl
2025-09-09 12:43:15 -07:00
parent 3d7aee19d2
commit 5d83cc43b2
4 changed files with 43 additions and 54 deletions

View File

@@ -7,7 +7,6 @@ from flask import current_app, request
from app import redis_client
from app.enums import InvitedOrgUserStatus
from app.notify_client import NotifyAdminAPIClient, _attach_current_user
from app.utils import hilite
from notifications_utils.url_safe_token import generate_token
@@ -34,23 +33,16 @@ class OrgInviteApiClient(NotifyAdminAPIClient):
)
state_key = f"login-state-{unquote(state)}"
redis_client.set(state_key, state, ex=ttl)
current_app.logger.debug(
hilite(f"SET THE STATE KEY TO {state} with state_key {state_key}")
)
# make and store the nonce
nonce = secrets.token_urlsafe()
nonce_key = f"login-nonce-{unquote(nonce)}"
redis_client.set(nonce_key, nonce, ex=ttl) # save the nonce to redis.
current_app.logger.debug(
hilite(f"SET THE STATE KEY TO {state} with state_key {state_key}")
)
data["nonce"] = nonce # This is passed to api for the invite url.
data["state"] = state # This is passed to api for the invite url.
resp = self.post(url="/organization/{}/invite".format(org_id), data=data)
current_app.logger.debug(hilite(f"RESP is {resp}"))
invite_data_key = f"invitedata-{unquote(state)}"
# For historical reasons 'invite' signifies a service invite
@@ -61,9 +53,6 @@ class OrgInviteApiClient(NotifyAdminAPIClient):
redis_invite_data = resp["data"]
redis_invite_data = json.dumps(redis_invite_data)
redis_client.set(invite_data_key, redis_invite_data, ex=ttl)
current_app.logger.debug(
hilite(f"SET invite_data_key {invite_data_key} to {redis_invite_data}")
)
return resp["data"]