mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
Merge branch 'main' into aanand-sqlalchemy-version-update
This commit is contained in:
@@ -20,13 +20,14 @@
|
||||
"Notify.gov makes it easy to keep people updated by helping you send text messages.",
|
||||
"",
|
||||
"",
|
||||
"Click this link to create an account on Notify.gov:",
|
||||
"",
|
||||
"[Join Service](((url)))",
|
||||
"If you’re new to Notify.gov you will first be directed to Login.gov create an account with us.",
|
||||
"",
|
||||
"",
|
||||
"This invitation will stop working at midnight tomorrow. This is to keep ((service_name)) secure."
|
||||
"This invitation will stop working at midnight tomorrow. This is to keep ((service_name)) secure.",
|
||||
"",
|
||||
"",
|
||||
"Notify.gov uses Login.gov to allow you to sign in safely. Login.gov is a secure sign in service to help you access participating government agencies' digital touchpoints."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -89,14 +89,6 @@ def invite_user_to_org(organization_id):
|
||||
ex=1800,
|
||||
)
|
||||
|
||||
# This is for the login.gov path, note 24 hour expiry to match
|
||||
# The expiration of invitations.
|
||||
redis_key = f"organization-invite-{invited_org_user.email_address}"
|
||||
redis_store.set(
|
||||
redis_key,
|
||||
organization_id,
|
||||
ex=3600 * 24,
|
||||
)
|
||||
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
|
||||
|
||||
return jsonify(data=invited_org_user.serialize()), 201
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime
|
||||
@@ -48,9 +49,25 @@ def _create_service_invite(invited_user, invite_link_host):
|
||||
current_app.config["SECRET_KEY"],
|
||||
current_app.config["DANGEROUS_SALT"],
|
||||
)
|
||||
|
||||
# The raw permissions are in the form "a,b,c,d"
|
||||
# but need to be in the form ["a", "b", "c", "d"]
|
||||
data = {}
|
||||
permissions = invited_user.permissions
|
||||
permissions = permissions.split(",")
|
||||
data["from_user_id"] = (str(invited_user.from_user.id))
|
||||
data["service_id"] = str(invited_user.service.id)
|
||||
data["permissions"] = permissions
|
||||
data["folder_permissions"] = invited_user.folder_permissions
|
||||
data["invited_user_id"] = str(invited_user.id)
|
||||
data["invited_user_email"] = invited_user.email_address
|
||||
|
||||
url = os.environ["LOGIN_DOT_GOV_REGISTRATION_URL"]
|
||||
url = url.replace("NONCE", token)
|
||||
url = url.replace("STATE", token)
|
||||
|
||||
user_data_url_safe = get_user_data_url_safe(data)
|
||||
|
||||
url = url.replace("STATE", user_data_url_safe)
|
||||
|
||||
personalisation = {
|
||||
"user_name": invited_user.from_user.name,
|
||||
@@ -75,32 +92,6 @@ def _create_service_invite(invited_user, invite_link_host):
|
||||
json.dumps(personalisation),
|
||||
ex=1800,
|
||||
)
|
||||
# The raw permissions are in the form "a,b,c,d"
|
||||
# but need to be in the form ["a", "b", "c", "d"]
|
||||
data = {}
|
||||
permissions = invited_user.permissions
|
||||
permissions = permissions.split(",")
|
||||
permission_list = []
|
||||
for permission in permissions:
|
||||
permission_list.append(f"{permission}")
|
||||
data["from_user_id"] = (str(invited_user.from_user.id),)
|
||||
data["service_id"] = str(invited_user.service.id)
|
||||
data["permissions"] = permission_list
|
||||
data["folder_permissions"] = invited_user.folder_permissions
|
||||
|
||||
# This is for the login.gov service invite on the
|
||||
# "Set Up Your Profile" path.
|
||||
redis_key = f"service-invite-{invited_user.email_address}"
|
||||
redis_store.raw_set(
|
||||
redis_key,
|
||||
json.dumps(data),
|
||||
ex=3600 * 24,
|
||||
)
|
||||
# TODO REMOVE DEBUG
|
||||
print(hilite(f"Save this data {data} with this redis_key {redis_key}"))
|
||||
did_we_save_it = redis_store.raw_get(redis_key)
|
||||
print(hilite(f"Did we save the data successfully? {did_we_save_it}"))
|
||||
# END DEBUG
|
||||
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
|
||||
|
||||
|
||||
@@ -223,3 +214,9 @@ def validate_service_invitation_token(token):
|
||||
|
||||
invited_user = get_invited_user_by_id(invited_user_id)
|
||||
return jsonify(data=invited_user_schema.dump(invited_user)), 200
|
||||
|
||||
|
||||
def get_user_data_url_safe(data):
|
||||
data = json.dumps(data)
|
||||
data = base64.b64encode(data.encode("utf8"))
|
||||
return data.decode("utf8")
|
||||
|
||||
Reference in New Issue
Block a user