From abf4a424b374f61497e35ac0931c000788fd9287 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Tue, 16 Jun 2020 22:35:58 +0100 Subject: [PATCH] Fixed #2865 --- .../Rule/Search/EmbyAvailabilityRuleTests.cs | 4 ++-- .../CustomizationSettingsTests.cs | 6 ++++-- .../Settings/Models/CustomizationSettings.cs | 14 ++++++++------ .../src/app/login/resetpassword.component.ts | 2 -- src/Ombi/Controllers/V1/IdentityController.cs | 6 ++++-- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Ombi.Core.Tests/Rule/Search/EmbyAvailabilityRuleTests.cs b/src/Ombi.Core.Tests/Rule/Search/EmbyAvailabilityRuleTests.cs index ca4b9a056..becbeadc9 100644 --- a/src/Ombi.Core.Tests/Rule/Search/EmbyAvailabilityRuleTests.cs +++ b/src/Ombi.Core.Tests/Rule/Search/EmbyAvailabilityRuleTests.cs @@ -70,7 +70,7 @@ namespace Ombi.Core.Tests.Rule.Search var result = await Rule.Execute(search); Assert.True(result.Success); - Assert.That(search.EmbyUrl, Is.EqualTo("http://test.com/#!/item.html?id=1")); + Assert.That(search.EmbyUrl, Is.EqualTo("http://test.com/#!/item?id=1")); } [Test] @@ -99,7 +99,7 @@ namespace Ombi.Core.Tests.Rule.Search var result = await Rule.Execute(search); Assert.True(result.Success); - Assert.That(search.EmbyUrl, Is.EqualTo("https://app.emby.media/#!/item.html?id=1")); + Assert.That(search.EmbyUrl, Is.EqualTo("https://app.emby.media/#!/item?id=1")); } [Test] diff --git a/src/Ombi.Settings.Tests/CustomizationSettingsTests.cs b/src/Ombi.Settings.Tests/CustomizationSettingsTests.cs index 6d83b99d9..ad0516305 100644 --- a/src/Ombi.Settings.Tests/CustomizationSettingsTests.cs +++ b/src/Ombi.Settings.Tests/CustomizationSettingsTests.cs @@ -15,9 +15,9 @@ namespace Tests { ApplicationUrl = applicationUrl }; - c.AddToUrl(append); + var result = c.AddToUrl(append); - return c.ApplicationUrl; + return result; } public static IEnumerable TestData @@ -25,6 +25,8 @@ namespace Tests get { yield return new TestCaseData("https://google.com/", "token?").Returns("https://google.com/token?").SetName("ForwardSlash_On_AppUrl_NotOn_Append"); + yield return new TestCaseData("https://google.com", "token?").Returns("https://google.com/token?").SetName("NoForwardSlash_On_AppUrl_NotOn_Append"); + yield return new TestCaseData(null, "token?").Returns(null).SetName("NullValue"); } } } diff --git a/src/Ombi.Settings/Settings/Models/CustomizationSettings.cs b/src/Ombi.Settings/Settings/Models/CustomizationSettings.cs index a9fcf8f83..040b6a110 100644 --- a/src/Ombi.Settings/Settings/Models/CustomizationSettings.cs +++ b/src/Ombi.Settings/Settings/Models/CustomizationSettings.cs @@ -12,22 +12,24 @@ public bool RecentlyAddedPage { get; set; } public bool UseCustomPage { get; set; } - public void AddToUrl(string part) + public string AddToUrl(string part) { - if (string.IsNullOrEmpty(ApplicationUrl)) + var appUrl = ApplicationUrl; + if (string.IsNullOrEmpty(appUrl)) { - ApplicationUrl = part; + return null; } - if (ApplicationUrl.EndsWith("/")) + if (appUrl.EndsWith("/")) { - ApplicationUrl = ApplicationUrl.Remove(ApplicationUrl.Length - 1); + appUrl = appUrl.Remove(ApplicationUrl.Length - 1); } if (!part.StartsWith("/")) { part = "/" + part; } - ApplicationUrl = ApplicationUrl + part; + appUrl = appUrl + part; + return appUrl; } } } \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/login/resetpassword.component.ts b/src/Ombi/ClientApp/src/app/login/resetpassword.component.ts index 7c228e962..0af4e86d4 100644 --- a/src/Ombi/ClientApp/src/app/login/resetpassword.component.ts +++ b/src/Ombi/ClientApp/src/app/login/resetpassword.component.ts @@ -13,7 +13,6 @@ import { IdentityService, ImageService, NotificationService, SettingsService } f export class ResetPasswordComponent implements OnInit { public form: FormGroup; - public customizationSettings: ICustomizationSettings; public emailSettingsEnabled: boolean; public baseUrl: string; public background: any; @@ -36,7 +35,6 @@ export class ResetPasswordComponent implements OnInit { if (base.length > 1) { this.baseUrl = base; } - this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x); this.settingsService.getEmailSettingsEnabled().subscribe(x => this.emailSettingsEnabled = x); } diff --git a/src/Ombi/Controllers/V1/IdentityController.cs b/src/Ombi/Controllers/V1/IdentityController.cs index af10b33fd..6afd7d70e 100644 --- a/src/Ombi/Controllers/V1/IdentityController.cs +++ b/src/Ombi/Controllers/V1/IdentityController.cs @@ -793,8 +793,10 @@ namespace Ombi.Controllers.V1 var emailSettings = await EmailSettings.GetSettingsAsync(); - customizationSettings.AddToUrl("/token?token="); - var url = customizationSettings.ApplicationUrl; + var appUrl = customizationSettings.AddToUrl("/token?token="); + var url = (string.IsNullOrEmpty(appUrl) + ? $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/token?token=" + : appUrl); if (user.UserType == UserType.PlexUser) {