1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

Improved code readability

This commit is contained in:
Sala-Sergiu 2024-08-01 18:07:34 +03:00
parent f5c771a057
commit bc7546ddaa
3 changed files with 11 additions and 28 deletions

View File

@ -82,11 +82,9 @@ public class PayPalIPNTransactionModel
IsAccountCredit = custom.Contains("account_credit:1");
}
private static string Extract(IReadOnlyDictionary<string, string> data, string key)
{
var success = data.TryGetValue(key, out var value);
return success ? value : null;
}
private static string Extract(IReadOnlyDictionary<string, string> data, string key) =>
data.TryGetValue(key, out var value) ? value : null;
private static DateTime ToUTCDateTime(string input)
{

View File

@ -31,8 +31,7 @@ namespace Bit.Identity.Controllers;
[ExceptionHandlerFilter]
public class AccountsController : Controller
{
private readonly ICurrentContext _currentContext;
private readonly ILogger<AccountsController> _logger;
private readonly ICurrentContext _currentContext;
private readonly IUserRepository _userRepository;
private readonly IRegisterUserCommand _registerUserCommand;
private readonly ICaptchaValidationService _captchaValidationService;
@ -44,8 +43,7 @@ public class AccountsController : Controller
private readonly IDataProtectorTokenFactory<RegistrationEmailVerificationTokenable> _registrationEmailVerificationTokenDataFactory;
public AccountsController(
ICurrentContext currentContext,
ILogger<AccountsController> logger,
ICurrentContext currentContext,
IUserRepository userRepository,
IRegisterUserCommand registerUserCommand,
ICaptchaValidationService captchaValidationService,
@ -57,8 +55,7 @@ public class AccountsController : Controller
IDataProtectorTokenFactory<RegistrationEmailVerificationTokenable> registrationEmailVerificationTokenDataFactory
)
{
_currentContext = currentContext;
_logger = logger;
_currentContext = currentContext;
_userRepository = userRepository;
_registerUserCommand = registerUserCommand;
_captchaValidationService = captchaValidationService;

View File

@ -41,25 +41,13 @@ public class RegisterRequestModel : IValidatableObject, ICaptchaProtectedModel
Email = Email,
MasterPasswordHint = MasterPasswordHint,
Kdf = Kdf.GetValueOrDefault(KdfType.PBKDF2_SHA256),
KdfIterations = KdfIterations.GetValueOrDefault(AuthConstants.PBKDF2_ITERATIONS.Default),
KdfIterations = KdfIterations ?? AuthConstants.PBKDF2_ITERATIONS.Default,
KdfMemory = KdfMemory,
KdfParallelism = KdfParallelism
KdfParallelism = KdfParallelism,
ReferenceData = ReferenceData != null ? JsonSerializer.Serialize(ReferenceData) : null,
Key = Key
};
if (ReferenceData != null)
{
user.ReferenceData = JsonSerializer.Serialize(ReferenceData);
}
if (Key != null)
{
user.Key = Key;
}
if (Keys != null)
{
Keys.ToUser(user);
}
Keys?.ToUser(user);
return user;
}