Fix login: Make username parameter case-insensitive
- Changed parameter names to uppercase (Username, Password) - Convert to lowercase internally for consistency - Fixes HTTP 500 error when form submits with lowercase field names
This commit is contained in:
parent
069930fe40
commit
0f9e92130c
@ -29,8 +29,12 @@ public class AccountController : Controller
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
// [ValidateAntiForgeryToken] // Temporarily disabled for HTTPS proxy issue
|
// [ValidateAntiForgeryToken] // Temporarily disabled for HTTPS proxy issue
|
||||||
public async Task<IActionResult> Login(string username, string password)
|
public async Task<IActionResult> Login(string Username, string Password)
|
||||||
{
|
{
|
||||||
|
// Make parameters case-insensitive for form compatibility
|
||||||
|
var username = Username?.ToLowerInvariant();
|
||||||
|
var password = Password;
|
||||||
|
|
||||||
Console.WriteLine($"Received Username: '{username}', Password: '{password}'");
|
Console.WriteLine($"Received Username: '{username}', Password: '{password}'");
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
|
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
|
||||||
@ -39,8 +43,8 @@ public class AccountController : Controller
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use AuthService to validate against database users
|
// Use AuthService to validate against database users (username already lowercase)
|
||||||
var loginDto = new LoginDto { Username = username, Password = password };
|
var loginDto = new LoginDto { Username = username!, Password = password };
|
||||||
var authResponse = await _authService.LoginAsync(loginDto);
|
var authResponse = await _authService.LoginAsync(loginDto);
|
||||||
|
|
||||||
if (authResponse != null)
|
if (authResponse != null)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user