Skip to content

Commit 3721852

Browse files
committed
TD-3730: error Screen modified
1 parent 5344942 commit 3721852

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

LearningHub.Nhs.WebUI/Controllers/HomeController.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ namespace LearningHub.Nhs.WebUI.Controllers
1515
using LearningHub.Nhs.WebUI.Helpers;
1616
using LearningHub.Nhs.WebUI.Interfaces;
1717
using LearningHub.Nhs.WebUI.Models;
18-
using Microsoft.ApplicationInsights.AspNetCore;
1918
using Microsoft.AspNetCore.Authentication;
2019
using Microsoft.AspNetCore.Authentication.Cookies;
2120
using Microsoft.AspNetCore.Authorization;
2221
using Microsoft.AspNetCore.Diagnostics;
2322
using Microsoft.AspNetCore.Hosting;
2423
using Microsoft.AspNetCore.Mvc;
24+
using Microsoft.Extensions.Configuration;
2525
using Microsoft.Extensions.Logging;
2626
using Microsoft.Extensions.Options;
2727
using Microsoft.FeatureManagement;
@@ -39,6 +39,7 @@ public class HomeController : BaseController
3939
private readonly IDashboardService dashboardService;
4040
private readonly IContentService contentService;
4141
private readonly IFeatureManager featureManager;
42+
private readonly Microsoft.Extensions.Configuration.IConfiguration configuration;
4243

4344
/// <summary>
4445
/// Initializes a new instance of the <see cref="HomeController"/> class.
@@ -53,6 +54,7 @@ public class HomeController : BaseController
5354
/// <param name="dashboardService">Dashboard service.</param>
5455
/// <param name="contentService">Content service.</param>
5556
/// <param name="featureManager"> featureManager.</param>
57+
/// <param name="configuration"> config.</param>
5658
public HomeController(
5759
IHttpClientFactory httpClientFactory,
5860
IWebHostEnvironment hostingEnvironment,
@@ -63,7 +65,8 @@ public HomeController(
6365
LearningHubAuthServiceConfig authConfig,
6466
IDashboardService dashboardService,
6567
IContentService contentService,
66-
IFeatureManager featureManager)
68+
IFeatureManager featureManager,
69+
Microsoft.Extensions.Configuration.IConfiguration configuration)
6770
: base(hostingEnvironment, httpClientFactory, logger, settings.Value)
6871
{
6972
this.authConfig = authConfig;
@@ -72,6 +75,7 @@ public HomeController(
7275
this.dashboardService = dashboardService;
7376
this.contentService = contentService;
7477
this.featureManager = featureManager;
78+
this.configuration = configuration;
7579
}
7680

7781
/// <summary>
@@ -168,6 +172,9 @@ public IActionResult Error(int? httpStatusCode)
168172
{
169173
if (originalPath == "/TooManyRequests")
170174
{
175+
this.ViewBag.Period = this.configuration["IpRateLimiting:GeneralRules:0:Period"];
176+
this.ViewBag.Limit = this.configuration["IpRateLimiting:GeneralRules:0:Limit"];
177+
171178
return this.View("TooManyRequests");
172179
}
173180
else

LearningHub.Nhs.WebUI/Views/Shared/TooManyRequests.cshtml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
@{
2-
ViewData["Title"] = "Too many requests";
2+
ViewData["Title"] = "Reset limit reached";
3+
// Get the value from ViewBag
4+
var period = ViewBag.Period.ToString();
5+
6+
// Remove the last character (if the string is not empty)
7+
if (!string.IsNullOrEmpty(period) && period.Length > 0)
8+
{
9+
period = period.Substring(0, period.Length - 1);
10+
}
311
}
412
<div class="bg-white">
513
<div class="nhsuk-width-container app-width-container">
614
<div class="nhsuk-grid-row">
715
<div class="nhsuk-grid-column-full nhsuk-u-padding-top-9 nhsuk-u-padding-bottom-7">
816
<h1 class="nhsuk-heading-xl"> @ViewData["Title"]</h1>
9-
<p>Too many requests have been made.</p>
10-
<p>If you need help, please contact the <a href="@ViewBag.SupportFormUrl" target="_blank">support team</a>.</p>
17+
<p>You've requested the maximum number of password resets (@ViewBag.Limit). Please wait @period minutes before trying again or contact the <a href="@ViewBag.SupportFormUrl" target="_blank">support team</a>.</p>
1118
<p>@DateTimeOffset.Now.ToString("d MMMM yyyy HH:mm:ss")</p>
1219
</div>
1320
</div>

0 commit comments

Comments
 (0)