Skip to content

Commit a1ee23c

Browse files
authored
refactor(identity): require ApplicationUrl for password reset emails (#5415)
* refactor(identity): require ApplicationUrl for password reset emails Simplify the reset-link construction in IdentityController by dropping the implicit fallback to HttpContext.Request.Host. The link is now sourced from the configured ApplicationUrl customization setting only; if it isn't set, the endpoint logs and returns the existing generic response without sending mail. Collapses the URL construction to a single source of truth and keeps the response shape identical across all branches. * refactor(identity): scope ApplicationUrl guard to local-user reset branch Move the missing-ApplicationUrl guard inside the local/Jellyfin/non-Connect Emby branch where the reset link is actually built. Plex and Emby Connect flows use hardcoded external URLs and don't depend on ApplicationUrl, so they continue to send reset emails regardless of configuration. Also drop the redundant `var url = appUrl` local and use `appUrl` directly.
1 parent 41a484a commit a1ee23c

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/Ombi/Controllers/V1/IdentityController.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,9 +797,6 @@ public async Task<OmbiIdentityResult> SubmitResetPassword([FromBody] SubmitPassw
797797
var emailSettings = await EmailSettings.GetSettingsAsync();
798798

799799
var appUrl = customizationSettings.AddToUrl("/token?token=");
800-
var url = (string.IsNullOrEmpty(appUrl)
801-
? $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/token?token="
802-
: appUrl);
803800

804801
if (user.UserType == UserType.PlexUser)
805802
{
@@ -825,6 +822,12 @@ await EmailProvider.SendAdHoc(new NotificationMessage
825822
}
826823
else
827824
{
825+
if (string.IsNullOrEmpty(appUrl))
826+
{
827+
_log.LogWarning("Password reset requested but ApplicationUrl is not configured; cannot build reset link.");
828+
return defaultMessage;
829+
}
830+
828831
// We have the user
829832
var token = await UserManager.GeneratePasswordResetTokenAsync(user);
830833
var encodedToken = WebUtility.UrlEncode(token);
@@ -835,7 +838,7 @@ await EmailProvider.SendAdHoc(new NotificationMessage
835838
Subject = $"{appName} Password Reset",
836839
Message =
837840
$"You recently made a request to reset your {appName} account. Please click the link below to complete the process.<br/><br/>" +
838-
$"<a href=\"{url}{encodedToken}\"> Reset </a>"
841+
$"<a href=\"{appUrl}{encodedToken}\"> Reset </a>"
839842
}, emailSettings);
840843
}
841844

0 commit comments

Comments
 (0)