migrate admin panel to actual accs, configs, etc (closes #16 and #13)

This commit is contained in:
Lapis
2026-06-18 11:17:50 -04:00
parent 004f1921a6
commit 3794e6e0ab
33 changed files with 1552 additions and 1255 deletions
@@ -1,9 +1,7 @@
@page "/change-password"
@attribute [Authorize]
@rendermode InteractiveServer
@using System.Security.Claims
@using CannedNet.Admin.Services
@inject AdminAuthService AuthService
@inject HttpClient Http
@inject NavigationManager Navigation
@inject IJSRuntime JSRuntime
@@ -44,8 +42,6 @@
</div>
@code {
[CascadingParameter] private Task<AuthenticationState>? AuthState { get; set; }
private string currentPassword = "";
private string newPassword = "";
private string confirmNewPassword = "";
@@ -75,17 +71,15 @@
return;
}
var state = await AuthState!;
var userIdClaim = state.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
if (userIdClaim == null || !int.TryParse(userIdClaim, out var userId))
var content = new FormUrlEncodedContent(new Dictionary<string, string>
{
message = "Error: Could not identify user.";
return;
}
["newPassword"] = newPassword
});
if (!AuthService.ChangePassword(userId, currentPassword, newPassword))
var response = await Http.PutAsync("/accounts/me/changepassword", content);
if (!response.IsSuccessStatusCode)
{
message = "Error: Current password is incorrect.";
message = "Error: Failed to change password.";
return;
}