PDF Polish (#2837)
Co-authored-by: William Brockhus <pickeringw@gmail.com>
This commit is contained in:
parent
6ed634f5d1
commit
752fda0e93
15 changed files with 103 additions and 106 deletions
|
|
@ -37,6 +37,9 @@ namespace API.Controllers;
|
|||
/// </summary>
|
||||
public class AccountController : BaseApiController
|
||||
{
|
||||
// Hardcoded to avoid localization multiple enumeration: https://github.com/Kareadita/Kavita/issues/2829
|
||||
private const string BadCredentialsMessage = "Your credentials are not correct";
|
||||
|
||||
private readonly UserManager<AppUser> _userManager;
|
||||
private readonly SignInManager<AppUser> _signInManager;
|
||||
private readonly ITokenService _tokenService;
|
||||
|
|
@ -204,7 +207,7 @@ public class AccountController : BaseApiController
|
|||
if (user == null)
|
||||
{
|
||||
_logger.LogWarning("Attempted login by {UserName} failed due to unable to find account", loginDto.Username);
|
||||
return Unauthorized(await _localizationService.Get("en", "bad-credentials"));
|
||||
return Unauthorized(BadCredentialsMessage);
|
||||
}
|
||||
var roles = await _userManager.GetRolesAsync(user);
|
||||
if (!roles.Contains(PolicyConstants.LoginRole)) return Unauthorized(await _localizationService.Translate(user.Id, "disabled-account"));
|
||||
|
|
@ -225,10 +228,10 @@ public class AccountController : BaseApiController
|
|||
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
var errorStr = await _localizationService.Translate(user.Id,
|
||||
result.IsNotAllowed ? "confirm-email" : "bad-credentials");
|
||||
_logger.LogWarning("{UserName} failed to log in at {Time}: {Issue}", user.UserName, user.LastActive,
|
||||
errorStr);
|
||||
string errorStr = result.IsNotAllowed
|
||||
? await _localizationService.Translate(user.Id, "confirm-email")
|
||||
: BadCredentialsMessage;
|
||||
_logger.LogWarning("{UserName} failed to log in at {Time}: {Issue}", user.UserName, user.LastActive, errorStr);
|
||||
return Unauthorized(errorStr);
|
||||
}
|
||||
}
|
||||
|
|
@ -858,7 +861,7 @@ public class AccountController : BaseApiController
|
|||
var user = await _unitOfWork.UserRepository.GetUserByEmailAsync(dto.Email);
|
||||
if (user == null)
|
||||
{
|
||||
return BadRequest(await _localizationService.Get("en", "bad-credentials"));
|
||||
return BadRequest(BadCredentialsMessage);
|
||||
}
|
||||
|
||||
try
|
||||
|
|
@ -868,7 +871,7 @@ public class AccountController : BaseApiController
|
|||
if (!result)
|
||||
{
|
||||
_logger.LogInformation("Unable to reset password, your email token is not correct: {@Dto}", dto);
|
||||
return BadRequest(await _localizationService.Translate(user.Id, "bad-credentials"));
|
||||
return BadRequest(BadCredentialsMessage);
|
||||
}
|
||||
|
||||
var errors = await _accountService.ChangeUserPassword(user, dto.Password);
|
||||
|
|
@ -948,12 +951,12 @@ public class AccountController : BaseApiController
|
|||
public async Task<ActionResult<UserDto>> ConfirmMigrationEmail(ConfirmMigrationEmailDto dto)
|
||||
{
|
||||
var user = await _unitOfWork.UserRepository.GetUserByEmailAsync(dto.Email);
|
||||
if (user == null) return BadRequest(await _localizationService.Get("en", "bad-credentials"));
|
||||
if (user == null) return BadRequest(BadCredentialsMessage);
|
||||
|
||||
if (!await ConfirmEmailToken(dto.Token, user))
|
||||
{
|
||||
_logger.LogInformation("confirm-migration-email email token is invalid");
|
||||
return BadRequest(await _localizationService.Translate(user.Id, "bad-credentials"));
|
||||
return BadRequest(BadCredentialsMessage);
|
||||
}
|
||||
|
||||
await _unitOfWork.CommitAsync();
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ public class UsersController : BaseApiController
|
|||
existingPreferences.ShareReviews = preferencesDto.ShareReviews;
|
||||
|
||||
existingPreferences.PdfTheme = preferencesDto.PdfTheme;
|
||||
existingPreferences.PdfLayoutMode = preferencesDto.PdfLayoutMode;
|
||||
existingPreferences.PdfScrollMode = preferencesDto.PdfScrollMode;
|
||||
existingPreferences.PdfSpreadMode = preferencesDto.PdfSpreadMode;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue