mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
Improve the validation around the Application URL
This commit is contained in:
parent
93b8f14c4d
commit
e059b521dd
4 changed files with 33 additions and 15 deletions
|
@ -279,4 +279,7 @@ export class SettingsService extends ServiceHelpers {
|
|||
return this.http
|
||||
.post<boolean>(`${this.url}/notifications/newsletter`, JSON.stringify(settings), {headers: this.headers});
|
||||
}
|
||||
public verifyUrl(url: string): Observable<boolean> {
|
||||
return this.http.post<boolean>(`${this.url}/customization/urlverify`, JSON.stringify({url}), {headers: this.headers});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,13 +43,24 @@ export class CustomizationComponent implements OnInit {
|
|||
}
|
||||
|
||||
public save() {
|
||||
this.settingsService.saveCustomization(this.settings).subscribe(x => {
|
||||
if (x) {
|
||||
this.notificationService.success("Successfully saved Ombi settings");
|
||||
} else {
|
||||
this.notificationService.success("There was an error when saving the Ombi settings");
|
||||
|
||||
this.settingsService.verifyUrl(this.settings.applicationUrl).subscribe(x => {
|
||||
if(this.settings.applicationUrl) {
|
||||
if(!x) {
|
||||
this.notificationService.error(`The URL "${this.settings.applicationUrl}" is not valid. Please format it correctly e.g. http://www.google.com/`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.settingsService.saveCustomization(this.settings).subscribe(x => {
|
||||
if (x) {
|
||||
this.notificationService.success("Successfully saved Ombi settings");
|
||||
} else {
|
||||
this.notificationService.success("There was an error when saving the Ombi settings");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public dropDownChange(event: any): void {
|
||||
|
|
|
@ -39,16 +39,6 @@ namespace Ombi.Controllers
|
|||
[Produces("application/json")]
|
||||
public class SettingsController : Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SettingsController" /> class.
|
||||
/// </summary>
|
||||
/// <param name="resolver">The resolver.</param>
|
||||
/// <param name="mapper">The mapper.</param>
|
||||
/// <param name="templateRepo">The templateRepo.</param>
|
||||
/// <param name="embyApi">The embyApi.</param>
|
||||
/// <param name="radarrSync">The radarrCacher.</param>
|
||||
/// <param name="memCache">The memory cache.</param>
|
||||
/// <param name="githubApi">The memory cache.</param>
|
||||
public SettingsController(ISettingsResolver resolver,
|
||||
IMapper mapper,
|
||||
INotificationTemplatesRepository templateRepo,
|
||||
|
@ -228,6 +218,13 @@ namespace Ombi.Controllers
|
|||
return await Save(settings);
|
||||
}
|
||||
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
[HttpPost("customization/urlverify")]
|
||||
public bool VerifyUrl([FromBody]UrlVerifyModel url)
|
||||
{
|
||||
return Uri.TryCreate(url.Url, UriKind.Absolute, out var __);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get's the preset themes available
|
||||
/// </summary>
|
||||
|
|
7
src/Ombi/Models/UrlVerifyModel.cs
Normal file
7
src/Ombi/Models/UrlVerifyModel.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace Ombi.Models
|
||||
{
|
||||
public class UrlVerifyModel
|
||||
{
|
||||
public string Url { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue