diff --git a/src/Lumina.Presentation.Web/Common/Models/UsersManagement/LoginRequestModel.cs b/src/Lumina.Presentation.Web/Common/Models/UsersManagement/LoginRequestModel.cs index d84581b9..650ff42c 100644 --- a/src/Lumina.Presentation.Web/Common/Models/UsersManagement/LoginRequestModel.cs +++ b/src/Lumina.Presentation.Web/Common/Models/UsersManagement/LoginRequestModel.cs @@ -10,9 +10,11 @@ namespace Lumina.Presentation.Web.Common.Models.UsersManagement; /// The username used to authenticate. /// The password used to authenticate. /// The TOTP (Time-Based One-Time Password) code used for two-factor authentication. +/// The URL to return to, after login. [DebuggerDisplay("Username: {Username}")] public record LoginRequestModel( string? Username = null, string? Password = null, - string? TotpCode = null + string? TotpCode = null, + string? ReturnUrl = null ); diff --git a/src/Lumina.Presentation.Web/Controllers/UsersManagement/AuthController.cs b/src/Lumina.Presentation.Web/Controllers/UsersManagement/AuthController.cs index 4845a986..0c2e2923 100644 --- a/src/Lumina.Presentation.Web/Controllers/UsersManagement/AuthController.cs +++ b/src/Lumina.Presentation.Web/Controllers/UsersManagement/AuthController.cs @@ -129,11 +129,10 @@ public class AuthController : Controller /// Logs in an account. /// /// User credentials used for login. - /// The url to return to, after login (if any). [AllowAnonymous] [ValidateAntiForgeryToken] [HttpPost("login")] - public async Task Login([FromBody] LoginRequestModel data, string? returnUrl = null) + public async Task Login([FromBody] LoginRequestModel data) { try { @@ -158,7 +157,7 @@ public class AuthController : Controller ClaimsIdentity claimsIdentity = new(claims, CookieAuthenticationDefaults.AuthenticationScheme); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity)); // return success status and redirect URL - return Json(new { success = true, data = string.IsNullOrEmpty(returnUrl) || !Url.IsLocalUrl(returnUrl) ? Url.Content("~/") : Url.Content(returnUrl) }); + return Json(new { success = true, data = string.IsNullOrEmpty(data.ReturnUrl) || !Url.IsLocalUrl(data.ReturnUrl) ? Url.Content("~/") : Url.Content(data.ReturnUrl) }); } catch (ApiException ex) { diff --git a/src/Lumina.Presentation.Web/Views/Auth/Login.cshtml b/src/Lumina.Presentation.Web/Views/Auth/Login.cshtml index ebfe6d3f..c779e8f8 100644 --- a/src/Lumina.Presentation.Web/Views/Auth/Login.cshtml +++ b/src/Lumina.Presentation.Web/Views/Auth/Login.cshtml @@ -54,9 +54,10 @@ @section Scripts {