Skip to content

fix: invitation accept-link rendering as null in invite/resend/update emails - #2056

Open
samark231 wants to merge 1 commit into
mainfrom
fix/invitation-email-null-link
Open

fix: invitation accept-link rendering as null in invite/resend/update emails#2056
samark231 wants to merge 1 commit into
mainfrom
fix/invitation-email-null-link

Conversation

@samark231

Copy link
Copy Markdown
Collaborator

Summary of Changes

Fixes the "Accept Invitation" button in team/role invitation emails resolving to a broken null link (DNS NXDOMAIN). When a user is invited to a team with a role (e.g. COUNSELLOR), the email's login URL was computed incorrectly and rendered as the literal string null.

Root cause: in InviteUserService.sendInvitationEmail, the null-guard checked learnerPortalUrl but assigned adminPortalUrl. For institutes that have a learner portal URL set but a null admin portal URL (the common case — admin_portal_base_url is a nullable column and Hibernate bypasses its DB default), the guard passed and overwrote the safe default with null. That null was then formatted into the email's href.

A second, independent bug is also fixed: the resend/update invitation emails used a static @Value field (ADMIN_LOGIN_URL), which Spring cannot inject — so it was always null, producing a permanent null/login link for every resend/update.

Backend:

  • InviteUserService.sendInvitationEmail: guard now checks adminPortalUrl (the field actually used) via StringUtils.hasText; falls back to https://dash.vacademy.io when unset.
  • Added normalizeUrl helper that prepends https:// to schemeless portal URLs (DB column default and some stored values have no scheme), preventing relative/broken links.
  • InviteUserService.sendReminderEmail: now resolves the institute's admin portal URL (same logic + fallback) and passes it into the reminder template.
  • InviteUserEmailBody: removed the broken static @Value adminPortalClientUrl and ADMIN_LOGIN_URL constant; createReminderEmail now accepts an adminLoginUrl parameter.

Frontend:

  • None.

Related Issue

N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

How Has This Been Tested?

  • Invited a user to a team with the COUNSELLOR role against a local auth_service; confirmed the "Accept Invitation" email link now renders a valid URL (https://dash.vacademy.io for an institute with no admin portal URL) instead of null.
  • Verified institutes with an explicit admin portal URL get that branded URL, scheme-normalized.
  • Verified resend/update invitation emails now produce a valid login link instead of null/login.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes
  • I have updated the documentation accordingly

@codacy-production

Copy link
Copy Markdown
Contributor

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 26 complexity

Metric Results
Complexity 26

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant