BTCPay-infrastructure-recovery

This commit is contained in:
sysadmin
2025-09-04 21:28:47 +01:00
parent b4cee007c4
commit be4d797c6c
22 changed files with 1552 additions and 101 deletions

View File

@@ -38,20 +38,29 @@ public class AccountController : Controller
return View();
}
if (username == "admin" && password == "admin")
// Use AuthService to validate against database users
var loginDto = new LoginDto { Username = username, Password = password };
var authResponse = await _authService.LoginAsync(loginDto);
if (authResponse != null)
{
var claims = new List<Claim>
// Get the actual user from database to get correct ID
var user = await _authService.GetUserByUsernameAsync(username);
if (user != null)
{
new(ClaimTypes.Name, "admin"),
new(ClaimTypes.NameIdentifier, Guid.NewGuid().ToString()),
new(ClaimTypes.Role, "Admin")
};
var claims = new List<Claim>
{
new(ClaimTypes.Name, user.Username),
new(ClaimTypes.NameIdentifier, user.Id.ToString()), // Use real database ID
new(ClaimTypes.Role, "Admin") // All users in admin system are admins
};
var identity = new ClaimsIdentity(claims, "Cookies");
var principal = new ClaimsPrincipal(identity);
var identity = new ClaimsIdentity(claims, "Cookies");
var principal = new ClaimsPrincipal(identity);
await HttpContext.SignInAsync("Cookies", principal);
return RedirectToAction("Index", "Dashboard");
await HttpContext.SignInAsync("Cookies", principal);
return RedirectToAction("Index", "Dashboard");
}
}
ModelState.AddModelError("", "Invalid username or password");