Skip to content

add support for nynorsk and english forgot password email template#2056

Merged
mgunnerud merged 3 commits into
mainfrom
fix/3601-stotte-epost-template-pa-engelsk-og-nynorsk-for-glemt-passord
Jun 23, 2026
Merged

add support for nynorsk and english forgot password email template#2056
mgunnerud merged 3 commits into
mainfrom
fix/3601-stotte-epost-template-pa-engelsk-og-nynorsk-for-glemt-passord

Conversation

@mgunnerud

@mgunnerud mgunnerud commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Description

  • add support for nynorsk and english forgot password email template, instead of always sending email in bokmål

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

Summary by CodeRabbit

Release Notes

  • New Features

    • Added multilingual support for self-identified account linking emails. Users can now receive authentication emails in Norwegian Bokmål, Norwegian Nynorsk, or English, with localized subject lines and content.
  • Tests

    • Enhanced test coverage for localized email verification across supported languages.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@mgunnerud, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 32 minutes and 53 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4bec8700-a08f-468a-a9d9-7c7aa5f2dd65

📥 Commits

Reviewing files that changed from the base of the PR and between c24ae2a and 85f1033.

📒 Files selected for processing (2)
  • src/Authentication/Controllers/SelfIdentifiedAuthenticationController.cs
  • test/Altinn.Platform.Authentication.Tests/Services/SelfIdentifiedLinkServiceTests.cs
📝 Walkthrough

Walkthrough

The PR adds localization support to the self-identified account-link email flow. SelfIdentifiedLinkSettings.EmailSubject changes from a single string to a Dictionary<string, string> keyed by locale. A lang parameter is threaded from the HTTP endpoint through the service interface and implementation, where it selects the localized subject and drives a lang-aware BuildEmailBody helper with a no_nb fallback.

Changes

Localized email for self-identified link

Layer / File(s) Summary
Configuration and interface contract
src/Authentication/Configuration/SelfIdentifiedLinkSettings.cs, src/Authentication/Services/Interfaces/ISelfIdentifiedLinkService.cs
EmailSubject property changes from string to Dictionary<string, string> keyed by locale (no_nb, no_nn, en). ISelfIdentifiedLinkService.RequestLinkAsync gains an optional lang parameter before CancellationToken.
Localized service implementation
src/Authentication/Services/SelfIdentifiedLinkService.cs
RequestLinkAsync adds optional lang; BuildEmailBody is replaced with a lang-aware version returning distinct HTML for no_nn, en, and a default Norwegian Bokmål template. Subject is selected via dictionary lookup with no_nb fallback, and SendEmailAsync receives the resolved localized subject and body.
Controller wiring and test coverage
src/Authentication/Controllers/SelfIdentifiedAuthenticationController.cs, test/Altinn.Platform.Authentication.Tests/Services/SelfIdentifiedLinkServiceTests.cs
RequestLink endpoint adds [FromQuery] string lang and forwards it to the service. Tests update EmailSubject to a language-keyed dictionary and convert the single [Fact] to a [Theory] with InlineData cases for each locale.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Alxandr
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for nynorsk and English language options for the forgot password email template, which aligns with the file summaries showing localization of email subjects and templates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/3601-stotte-epost-template-pa-engelsk-og-nynorsk-for-glemt-passord

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Authentication/Controllers/SelfIdentifiedAuthenticationController.cs (1)

82-92: ⚠️ Potential issue | 🟠 Major

Make lang optional at the HTTP boundary.

Line 82 currently declares lang as a non-nullable string parameter with [FromQuery], which ASP.NET Core treats as required when nullable reference types are enabled (file has #nullable enable). This breaks the intended "default to empty string when not set" behavior and will reject existing callers that omit lang. The service method signature already expects this flexibility with string lang = "".

Suggested fix
-        public async Task<ActionResult> RequestLink([FromQuery] string lang, [FromBody] SelfIdentifiedLinkRequest request, CancellationToken cancellationToken)
+        public async Task<ActionResult> RequestLink([FromQuery] string? lang, [FromBody] SelfIdentifiedLinkRequest request, CancellationToken cancellationToken)
         {
@@
-            string? maskedEmail = await _linkService.RequestLinkAsync(request.UserName, toPartyUuid, lang, cancellationToken);
+            string? maskedEmail = await _linkService.RequestLinkAsync(request.UserName, toPartyUuid, lang ?? string.Empty, cancellationToken);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Authentication/Controllers/SelfIdentifiedAuthenticationController.cs`
around lines 82 - 92, The lang parameter in the RequestLink method is currently
declared as a non-nullable string, which causes ASP.NET Core to treat it as
required when nullable reference types are enabled, breaking callers that omit
it. Change the lang parameter type from string to string? in the method
signature to make it optional at the HTTP boundary, allowing the service layer
to handle the default empty string behavior as intended.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@test/Altinn.Platform.Authentication.Tests/Services/SelfIdentifiedLinkServiceTests.cs`:
- Around line 52-55: The RequestLink_ValidTarget_MintsTokenAndSendsEmailWithLink
test method currently only validates the default empty language code and English
language code through InlineData attributes. Add two additional InlineData test
cases to cover the nynorsk language path (with language code "no_nn" and its
corresponding expected subject) and the unknown-language fallback scenario (with
a non-existent language code and the fallback expected subject). This ensures
the new nynorsk path and fallback branch logic are properly tested alongside the
existing cases.

---

Outside diff comments:
In `@src/Authentication/Controllers/SelfIdentifiedAuthenticationController.cs`:
- Around line 82-92: The lang parameter in the RequestLink method is currently
declared as a non-nullable string, which causes ASP.NET Core to treat it as
required when nullable reference types are enabled, breaking callers that omit
it. Change the lang parameter type from string to string? in the method
signature to make it optional at the HTTP boundary, allowing the service layer
to handle the default empty string behavior as intended.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7347d332-c978-406c-9ab5-13ac80c5c38a

📥 Commits

Reviewing files that changed from the base of the PR and between a772d36 and c24ae2a.

📒 Files selected for processing (5)
  • src/Authentication/Configuration/SelfIdentifiedLinkSettings.cs
  • src/Authentication/Controllers/SelfIdentifiedAuthenticationController.cs
  • src/Authentication/Services/Interfaces/ISelfIdentifiedLinkService.cs
  • src/Authentication/Services/SelfIdentifiedLinkService.cs
  • test/Altinn.Platform.Authentication.Tests/Services/SelfIdentifiedLinkServiceTests.cs

@sonarqubecloud

Copy link
Copy Markdown

@mgunnerud mgunnerud requested a review from TheTechArch June 22, 2026 12:51

@TheTechArch TheTechArch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦖

@mgunnerud mgunnerud merged commit a78ed06 into main Jun 23, 2026
9 of 10 checks passed
@mgunnerud mgunnerud deleted the fix/3601-stotte-epost-template-pa-engelsk-og-nynorsk-for-glemt-passord branch June 23, 2026 10:00
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.

Støtte epost-template på engelsk og nynorsk for glemt passord

2 participants