Stats Page Overhaul (#4292)

Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
This commit is contained in:
Joe Milazzo
2025-12-19 13:23:55 -07:00
committed by GitHub
parent 20197fa712
commit e1f421ccc0
175 changed files with 12122 additions and 5746 deletions
+24 -1
View File
@@ -152,6 +152,12 @@ public class AccountController : BaseApiController
new ApiException(400,
await _localizationService.Translate(UserId, "password-required")));
var oidcConfig = (await _unitOfWork.SettingsRepository.GetSettingsDtoAsync()).OidcConfig;
if (user.IdentityProvider == IdentityProvider.OpenIdConnect && oidcConfig is {Enabled: true, SyncUserSettings: true})
{
return BadRequest(await _localizationService.Translate(user.Id, "oidc-managed"));
}
// If you're an admin and the username isn't yours, you don't need to validate the password
var isResettingOtherUser = (resetPasswordDto.UserName != Username! && isAdmin);
if (!isResettingOtherUser && !await _userManager.CheckPasswordAsync(user, resetPasswordDto.OldPassword))
@@ -330,6 +336,7 @@ public class AccountController : BaseApiController
pref.Theme ??= await _unitOfWork.SiteThemeRepository.GetDefaultTheme();
dto.Preferences = _mapper.Map<UserPreferencesDto>(pref);
dto.AuthKeys = _mapper.Map<List<AuthKeyDto>>(user.AuthKeys);
return dto;
}
@@ -397,6 +404,11 @@ public class AccountController : BaseApiController
if (user == null || dto == null || string.IsNullOrEmpty(dto.Email) || string.IsNullOrEmpty(dto.Password))
return BadRequest(await _localizationService.Translate(UserId, "invalid-payload"));
var oidcConfig = (await _unitOfWork.SettingsRepository.GetSettingsDtoAsync()).OidcConfig;
if (user.IdentityProvider == IdentityProvider.OpenIdConnect && oidcConfig is {Enabled: true, SyncUserSettings: true})
{
return BadRequest(await _localizationService.Translate(user.Id, "oidc-managed"));
}
// Validate this user's password
if (! await _userManager.CheckPasswordAsync(user, dto.Password))
@@ -508,6 +520,12 @@ public class AccountController : BaseApiController
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(Username!);
if (user == null) return Unauthorized(await _localizationService.Translate(UserId, "permission-denied"));
var oidcConfig = (await _unitOfWork.SettingsRepository.GetSettingsDtoAsync()).OidcConfig;
if (user.IdentityProvider == IdentityProvider.OpenIdConnect && oidcConfig is {Enabled: true, SyncUserSettings: true})
{
return BadRequest(await _localizationService.Translate(user.Id, "oidc-managed"));
}
var isAdmin = await _unitOfWork.UserRepository.IsUserAdminAsync(user);
if (!await _accountService.CanChangeAgeRestriction(user)) return BadRequest(await _localizationService.Translate(UserId, "permission-denied"));
@@ -550,7 +568,6 @@ public class AccountController : BaseApiController
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(dto.UserId, AppUserIncludes.SideNavStreams);
if (user == null) return BadRequest(await _localizationService.Translate(UserId, "no-user"));
try
{
if (await _accountService.ChangeIdentityProvider(UserId, user, dto.IdentityProvider)) return Ok();
@@ -971,6 +988,12 @@ public class AccountController : BaseApiController
return Ok(await _localizationService.Get("en", "forgot-password-generic"));
}
var oidcConfig = (await _unitOfWork.SettingsRepository.GetSettingsDtoAsync()).OidcConfig;
if (user.IdentityProvider == IdentityProvider.OpenIdConnect && oidcConfig is {Enabled: true, SyncUserSettings: true})
{
return BadRequest(await _localizationService.Translate(user.Id, "oidc-managed"));
}
var roles = await _userManager.GetRolesAsync(user);
if (!roles.Any(r => r is PolicyConstants.AdminRole or PolicyConstants.ChangePasswordRole or PolicyConstants.ReadOnlyRole))
return Unauthorized(await _localizationService.Translate(user.Id, "permission-denied"));