BTCPay-infrastructure-recovery
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user