using Bit.Core.Billing.Premium.Models; using Bit.Core.Entities; using Bit.Core.KeyManagement.Models.Data; using Bit.Core.KeyManagement.UserKey; using Bit.Core.Models.Data; #nullable enable namespace Bit.Core.Repositories; public interface IUserRepository : IRepository { Task GetByEmailAsync(string email); Task> GetManyByEmailsAsync(IEnumerable emails); Task GetBySsoUserAsync(string externalId, Guid? organizationId); Task GetKdfInformationByEmailAsync(string email); Task> SearchAsync(string email, int skip, int take); Task> GetManyByPremiumAsync(bool premium); Task GetPublicKeyAsync(Guid id); Task GetAccountRevisionDateAsync(Guid id); Task UpdateStorageAsync(Guid id); Task UpdateRenewalReminderDateAsync(Guid id, DateTime renewalReminderDate); Task> GetManyAsync(IEnumerable ids); /// /// Retrieves the data for the requested user IDs and includes an additional property indicating /// whether the user has premium access directly or through an organization. /// [Obsolete("Use GetPremiumAccessByIdsAsync instead. This method will be removed in a future version.")] Task> GetManyWithCalculatedPremiumAsync(IEnumerable ids); /// /// Retrieves the data for the requested user ID and includes additional property indicating /// whether the user has premium access directly or through an organization. /// /// Calls the same stored procedure as GetManyWithCalculatedPremiumAsync but handles the query /// for a single user. /// /// The user ID to retrieve data for. /// User data with calculated premium access; null if nothing is found [Obsolete("Use GetPremiumAccessAsync instead. This method will be removed in a future version.")] Task GetCalculatedPremiumAsync(Guid userId); /// /// Retrieves premium access status for multiple users. /// For internal use - consumers should use IHasPremiumAccessQuery instead. /// /// The user IDs to check /// Collection of UserPremiumAccess objects containing premium status information Task> GetPremiumAccessByIdsAsync(IEnumerable ids); /// /// Retrieves premium access status for a single user. /// For internal use - consumers should use IHasPremiumAccessQuery instead. /// /// The user ID to check /// UserPremiumAccess object containing premium status information, or null if user not found Task GetPremiumAccessAsync(Guid userId); /// /// Sets a new user key and updates all encrypted data. /// Warning: Any user key encrypted data not included will be lost. /// /// The user to update /// Registered database calls to update re-encrypted data. Task UpdateUserKeyAndEncryptedDataAsync(User user, IEnumerable updateDataActions); Task UpdateUserKeyAndEncryptedDataV2Async(User user, IEnumerable updateDataActions); /// /// Sets the account cryptographic state to a user in a single transaction. The provided /// MUST be a V2 encryption state. Passing in a V1 encryption state will throw. /// Extra actions can be passed in case other user data needs to be updated in the same transaction. /// Task SetV2AccountCryptographicStateAsync( Guid userId, UserAccountKeysData accountKeysData, IEnumerable? updateUserDataActions = null); Task DeleteManyAsync(IEnumerable users); } public delegate Task UpdateUserData(Microsoft.Data.SqlClient.SqlConnection? connection = null, Microsoft.Data.SqlClient.SqlTransaction? transaction = null);