Skip to content

Commit

Permalink
24363 - New magic link formatting based if FF is on (#3166)
Browse files Browse the repository at this point in the history
  • Loading branch information
JazzarKarim authored Dec 3, 2024
1 parent 0abeb48 commit 9cab865
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions auth-api/src/auth_api/services/affiliation_invitation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from auth_api.models.org import Org as OrgModel
from auth_api.schemas import AffiliationInvitationSchema
from auth_api.services.entity import Entity as EntityService
from auth_api.services.flags import flags
from auth_api.services.org import Org as OrgService
from auth_api.services.user import User as UserService
from auth_api.utils.enums import AccessType, AffiliationInvitationType, InvitationStatus, LoginSource, Status
Expand Down Expand Up @@ -477,12 +478,27 @@ def find_affiliation_invitation_by_id(invitation_id):
@staticmethod
def _get_token_confirm_path(app_url, org_name, token, query_params=None):
"""Get the config for different email types."""
escape_url = escape_wam_friendly_url(org_name)
path = f"{escape_url}/affiliationInvitation/acceptToken"
token_confirm_url = f"{app_url}/{path}/{token}"
if flags.is_on("enable-new-magic-link-formatting-with-query-params", default=False):
# New query parameter based URL structure
params = {
"token": token,
"orgName": escape_wam_friendly_url(org_name),
}

# Add any additional query params
if query_params:
params.update(query_params)

# Build the URL with query parameters
token_confirm_url = f"{app_url}/affiliationInvitation/acceptToken?{urlencode(params)}"
else:
# Original URL structure
escape_url = escape_wam_friendly_url(org_name)
path = f"{escape_url}/affiliationInvitation/acceptToken"
token_confirm_url = f"{app_url}/{path}/{token}"

if query_params:
token_confirm_url += f"?{urlencode(query_params)}"
if query_params:
token_confirm_url += f"?{urlencode(query_params)}"

return token_confirm_url

Expand Down

0 comments on commit 9cab865

Please sign in to comment.