diff --git a/Controllers/LoginController.cs b/Controllers/LoginController.cs index 1358dd3..80121fb 100644 --- a/Controllers/LoginController.cs +++ b/Controllers/LoginController.cs @@ -26,9 +26,9 @@ namespace CarCareTracker.Controllers _logger = logger; _loginLogic = loginLogic; } - public IActionResult Index() + public IActionResult Index(string redirectURL = "") { - return View(); + return View(model: redirectURL); } public IActionResult Registration() { diff --git a/Middleware/Authen.cs b/Middleware/Authen.cs index 9de2ddd..7c7b5dc 100644 --- a/Middleware/Authen.cs +++ b/Middleware/Authen.cs @@ -157,7 +157,13 @@ namespace CarCareTracker.Middleware return Task.CompletedTask; } } - Response.Redirect("/Login/Index"); + if (Request.Path.Value == "/Vehicle/Index" && Request.QueryString.HasValue) + { + Response.Redirect($"/Login/Index?redirectURL={Request.Path.Value}{Request.QueryString.Value}"); + } else + { + Response.Redirect("/Login/Index"); + } return Task.CompletedTask; } protected override Task HandleForbiddenAsync(AuthenticationProperties properties) diff --git a/Views/Login/Index.cshtml b/Views/Login/Index.cshtml index cee4978..f39d78b 100644 --- a/Views/Login/Index.cshtml +++ b/Views/Login/Index.cshtml @@ -1,6 +1,7 @@ @using CarCareTracker.Helper @inject IConfigHelper config @inject ITranslationHelper translator +@model string @{ var logoUrl = config.GetLogoUrl(); var userLanguage = config.GetServerLanguage(); @@ -38,4 +39,9 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/Views/Shared/401.cshtml b/Views/Shared/401.cshtml index 6a9e903..8b70feb 100644 --- a/Views/Shared/401.cshtml +++ b/Views/Shared/401.cshtml @@ -1 +1,8 @@ -