Add comments by AI

This commit is contained in:
2026-04-10 20:34:25 +02:00
parent 86e50c35ab
commit 61ed4bc223
@@ -23,6 +23,11 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods #region Public Methods
/// <summary>
/// Adds a new user to the system.
/// </summary>
/// <param name="newUser">The User entity containing the new user data.</param>
/// <param name="isAdmin">Whether the new user should have admin privileges.</param>
public bool AddNewUser(User newUser, bool isAdmin = false) public bool AddNewUser(User newUser, bool isAdmin = false)
{ {
newUser.Password = EncryptPassword(newUser.Password); newUser.Password = EncryptPassword(newUser.Password);
@@ -45,11 +50,22 @@ namespace skydiveLogs_api.DomainBusiness
return result; return result;
} }
/// <summary>
/// Retrieves a user by their ID.
/// </summary>
/// <param name="userId">The user ID to retrieve.</param>
/// <returns>A User entity containing the user details.</returns>
public User GetById(int userId) public User GetById(int userId)
{ {
return _userRepository.GetById(userId); return _userRepository.GetById(userId);
} }
/// <summary>
/// Retrieves a user by their login and password.
/// </summary>
/// <param name="login">The login name of the user.</param>
/// <param name="password">The password to verify the user.</param>
/// <returns>A User entity containing the user details.</returns>
public User GetByLogin(string login, string password) public User GetByLogin(string login, string password)
{ {
return _userRepository.GetByLogin(login, EncryptPassword(password)); return _userRepository.GetByLogin(login, EncryptPassword(password));
@@ -69,7 +85,7 @@ namespace skydiveLogs_api.DomainBusiness
{ {
Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(encryptionKey, Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(encryptionKey,
new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 }, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 },
3, 3,
HashAlgorithmName.SHA256); HashAlgorithmName.SHA256);
encryptor.Key = pdb.GetBytes(32); encryptor.Key = pdb.GetBytes(32);
encryptor.IV = pdb.GetBytes(16); encryptor.IV = pdb.GetBytes(16);
@@ -97,4 +113,4 @@ namespace skydiveLogs_api.DomainBusiness
#endregion Private Fields #endregion Private Fields
} }
} }