Skip to content

Commit 41000c9

Browse files
authored
32485 - Correct login source displayed in account creation email (#3660)
1 parent 553921e commit 41000c9

File tree

4 files changed

+57
-53
lines changed

4 files changed

+57
-53
lines changed

auth-api/src/auth_api/services/org.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -980,13 +980,13 @@ def change_org_status(self, status_code, suspension_reason_code):
980980
return Org(org_model)
981981

982982
@staticmethod
983-
def approve_or_reject(org_id: int, is_approved: bool, task_action: str = None):
983+
def approve_or_reject(org_id: int, is_approved: bool, client_id: int, task_action: str = None):
984984
"""Mark the affidavit as approved or rejected."""
985985
current_app.logger.debug("<find_affidavit_by_org_id ")
986986
# Get the org and check what's the current status
987987
org: OrgModel = OrgModel.find_by_org_id(org_id)
988988

989-
# Current User
989+
# Current User - usually staff admin
990990
user: UserModel = UserModel.find_by_jwt_token()
991991

992992
if task_action == TaskAction.AFFIDAVIT_REVIEW.value:
@@ -1007,10 +1007,10 @@ def approve_or_reject(org_id: int, is_approved: bool, task_action: str = None):
10071007
admin_emails = UserService.get_admin_emails_for_org(org_id)
10081008
if admin_emails != "":
10091009
if org.access_type in (AccessType.EXTRA_PROVINCIAL.value, AccessType.REGULAR_BCEID.value):
1010-
Org.send_approved_rejected_notification(admin_emails, org.name, org.id, org.status_code, user)
1010+
Org.send_approved_rejected_notification(admin_emails, org.name, org.id, org.status_code, client_id)
10111011
elif org.access_type in (AccessType.GOVM.value, AccessType.GOVN.value):
10121012
Org.send_approved_rejected_govm_govn_notification(
1013-
admin_emails, org.name, org.id, org.status_code, user
1013+
admin_emails, org.name, org.id, org.status_code, client_id
10141014
)
10151015
else:
10161016
# continue but log error
@@ -1051,7 +1051,7 @@ def send_staff_review_account_reminder(relationship_id, task_relationship_type=T
10511051
raise BusinessException(Error.FAILED_NOTIFICATION, None) from e
10521052

10531053
@staticmethod
1054-
def send_approved_rejected_notification(receipt_admin_emails, org_name, org_id, org_status: OrgStatus, user: UserModel = None):
1054+
def send_approved_rejected_notification(receipt_admin_emails, org_name, org_id, org_status: OrgStatus, client_id: int):
10551055
"""Send Approved/Rejected notification to the user."""
10561056
current_app.logger.debug("<send_approved_rejected_notification")
10571057

@@ -1062,12 +1062,13 @@ def send_approved_rejected_notification(receipt_admin_emails, org_name, org_id,
10621062
else:
10631063
return # Don't send mail for any other status change
10641064
app_url = current_app.config.get("WEB_APP_URL")
1065+
client: UserModel = UserModel.find_by_id(client_id)
10651066
data = {
10661067
"accountId": org_id,
10671068
"emailAddresses": receipt_admin_emails,
10681069
"contextUrl": app_url,
10691070
"orgName": org_name,
1070-
"loginSource": user.login_source
1071+
"loginSource": client.login_source
10711072
}
10721073
try:
10731074
publish_to_mailer(notification_type, data=data)
@@ -1078,7 +1079,7 @@ def send_approved_rejected_notification(receipt_admin_emails, org_name, org_id,
10781079

10791080
@staticmethod
10801081
def send_approved_rejected_govm_govn_notification(
1081-
receipt_admin_email, org_name, org_id, org_status: OrgStatus, origin_url, user: UserModel
1082+
receipt_admin_email, org_name, org_id, org_status: OrgStatus, origin_url, client_id: int
10821083
):
10831084
"""Send Approved govm notification to the user."""
10841085
current_app.logger.debug("<send_approved_rejected_govm_govn_notification")
@@ -1090,7 +1091,8 @@ def send_approved_rejected_govm_govn_notification(
10901091
else:
10911092
return # Don't send mail for any other status change
10921093
app_url = f"{origin_url}/"
1093-
data = {"accountId": org_id, "emailAddresses": receipt_admin_email, "contextUrl": app_url, "orgName": org_name, "loginSource": user.login_source}
1094+
client: UserModel = UserModel.find_by_id(client_id)
1095+
data = {"accountId": org_id, "emailAddresses": receipt_admin_email, "contextUrl": app_url, "orgName": org_name, "loginSource": client.login_source}
10941096
try:
10951097
publish_to_mailer(notification_type, data=data)
10961098
current_app.logger.debug("send_approved_rejected_govm_govn_notification>")

auth-api/src/auth_api/services/task.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ def _update_relationship(self):
119119
if task_model.relationship_type == TaskRelationshipType.ORG.value:
120120
# Update Org relationship
121121
org_id = task_model.relationship_id
122+
122123
if not is_hold:
123124
self._update_org(
124-
is_approved=is_approved, org_id=org_id, task_action=task_model.action
125+
is_approved=is_approved, org_id=org_id, client_id=task_model.created_by_id, task_action=task_model.action
125126
)
126127
else:
127128
# Task with ACCOUNT_REVIEW action cannot be put on hold
@@ -223,14 +224,14 @@ def _notify_admin_about_hold(
223224
raise BusinessException(Error.FAILED_NOTIFICATION, None) from e
224225

225226
@staticmethod
226-
def _update_org(is_approved: bool, org_id: int, task_action: str = None):
227+
def _update_org(is_approved: bool, org_id: int, client_id: int, task_action: str = None):
227228
"""Approve/Reject Affidavit and Org."""
228229
from auth_api.services import Org as OrgService # pylint:disable=cyclic-import, import-outside-toplevel
229230

230231
current_app.logger.debug("<update_task_org ")
231232

232233
OrgService.approve_or_reject(
233-
org_id=org_id, is_approved=is_approved, task_action=task_action
234+
org_id=org_id, is_approved=is_approved, client_id=client_id, task_action=task_action
234235
)
235236

236237
current_app.logger.debug(">update_task_org ")

queue_services/account-mailer/poetry.lock

Lines changed: 41 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

queue_services/account-mailer/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ packages = [
1313

1414
[tool.poetry.dependencies]
1515
python = ">=3.12,<3.13"
16-
blinker = "1.8.2"
16+
blinker = ">=1.9.0"
1717
charset-normalizer = "3.3.2"
1818
click = "8.1.7"
1919
expiringdict = "1.2.2"
@@ -38,7 +38,7 @@ urllib3 = "2.6.3"
3838
zipp = "3.19.1"
3939

4040
# VCS dependencies
41-
auth-api = { git = "https://github.com/seeker25/sbc-auth.git", branch = "32356", subdirectory = "auth-api" }
41+
auth-api = { git = "https://github.com/bcgov/sbc-auth.git", branch = "main", subdirectory = "auth-api" }
4242
simple-cloudevent = { git = "https://github.com/daxiom/simple-cloudevent.py.git" }
4343
cloud-sql-python-connector = "^1.13.0"
4444
pkginfo = "^1.12.1.2"

0 commit comments

Comments
 (0)