2022-06-30 01:46:41 +02:00
|
|
|
|
using System.Security.Claims;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Entities;
|
2017-06-07 20:14:34 +02:00
|
|
|
|
using Bit.Core.Enums;
|
|
|
|
|
using Bit.Core.Models;
|
2017-06-22 04:33:45 +02:00
|
|
|
|
using Bit.Core.Models.Business;
|
2021-03-22 23:21:43 +01:00
|
|
|
|
using Fido2NetLib;
|
2016-05-20 01:10:24 +02:00
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
2015-12-09 04:57:38 +01:00
|
|
|
|
|
|
|
|
|
namespace Bit.Core.Services;
|
2022-08-29 22:06:55 +02:00
|
|
|
|
|
2015-12-09 04:57:38 +01:00
|
|
|
|
public interface IUserService
|
|
|
|
|
{
|
2017-01-14 16:02:37 +01:00
|
|
|
|
Guid? GetProperUserId(ClaimsPrincipal principal);
|
2017-01-12 03:46:36 +01:00
|
|
|
|
Task<User> GetUserByIdAsync(string userId);
|
2016-05-21 23:16:22 +02:00
|
|
|
|
Task<User> GetUserByIdAsync(Guid userId);
|
2017-01-25 04:46:54 +01:00
|
|
|
|
Task<User> GetUserByPrincipalAsync(ClaimsPrincipal principal);
|
2017-01-14 16:02:37 +01:00
|
|
|
|
Task<DateTime> GetAccountRevisionDateByIdAsync(Guid userId);
|
2017-08-14 19:06:44 +02:00
|
|
|
|
Task SaveUserAsync(User user, bool push = false);
|
2018-05-24 22:53:07 +02:00
|
|
|
|
Task<IdentityResult> RegisterUserAsync(User user, string masterPassword, string token, Guid? orgUserId);
|
2020-08-13 23:30:10 +02:00
|
|
|
|
Task<IdentityResult> RegisterUserAsync(User user);
|
2015-12-09 04:57:38 +01:00
|
|
|
|
Task SendMasterPasswordHintAsync(string email);
|
2022-04-01 22:08:47 +02:00
|
|
|
|
Task SendTwoFactorEmailAsync(User user, bool isBecauseNewDeviceLogin = false);
|
2017-06-20 16:08:59 +02:00
|
|
|
|
Task<bool> VerifyTwoFactorEmailAsync(User user, string token);
|
2021-03-22 23:21:43 +01:00
|
|
|
|
Task<CredentialCreateOptions> StartWebAuthnRegistrationAsync(User user);
|
|
|
|
|
Task<bool> DeleteWebAuthnKeyAsync(User user, int id);
|
|
|
|
|
Task<bool> CompleteWebAuthRegistrationAsync(User user, int value, string name, AuthenticatorAttestationRawResponse attestationResponse);
|
2017-07-02 05:20:19 +02:00
|
|
|
|
Task SendEmailVerificationAsync(User user);
|
|
|
|
|
Task<IdentityResult> ConfirmEmailAsync(User user, string token);
|
2015-12-09 04:57:38 +01:00
|
|
|
|
Task InitiateEmailChangeAsync(User user, string newEmail);
|
2017-05-31 15:54:32 +02:00
|
|
|
|
Task<IdentityResult> ChangeEmailAsync(User user, string masterPassword, string newEmail, string newMasterPassword,
|
|
|
|
|
string token, string key);
|
2022-07-11 15:28:14 +02:00
|
|
|
|
Task<IdentityResult> ChangePasswordAsync(User user, string masterPassword, string newMasterPassword, string passwordHint, string key);
|
2020-10-13 22:00:33 +02:00
|
|
|
|
Task<IdentityResult> SetPasswordAsync(User user, string newMasterPassword, string key, string orgIdentifier = null);
|
2021-11-09 16:37:32 +01:00
|
|
|
|
Task<IdentityResult> SetKeyConnectorKeyAsync(User user, string key, string orgIdentifier);
|
|
|
|
|
Task<IdentityResult> ConvertToKeyConnectorAsync(User user);
|
2021-05-19 16:40:32 +02:00
|
|
|
|
Task<IdentityResult> AdminResetPasswordAsync(OrganizationUserType type, Guid orgId, Guid id, string newMasterPassword, string key);
|
2021-08-05 20:00:24 +02:00
|
|
|
|
Task<IdentityResult> UpdateTempPasswordAsync(User user, string newMasterPassword, string key, string hint);
|
2018-08-14 21:30:04 +02:00
|
|
|
|
Task<IdentityResult> ChangeKdfAsync(User user, string masterPassword, string newMasterPassword, string key,
|
|
|
|
|
KdfType kdf, int kdfIterations);
|
2017-05-31 15:54:32 +02:00
|
|
|
|
Task<IdentityResult> UpdateKeyAsync(User user, string masterPassword, string key, string privateKey,
|
2021-07-01 22:27:03 +02:00
|
|
|
|
IEnumerable<Cipher> ciphers, IEnumerable<Folder> folders, IEnumerable<Send> sends);
|
2015-12-09 04:57:38 +01:00
|
|
|
|
Task<IdentityResult> RefreshSecurityStampAsync(User user, string masterPasswordHash);
|
2022-04-28 23:42:47 +02:00
|
|
|
|
Task UpdateTwoFactorProviderAsync(User user, TwoFactorProviderType type, bool setEnabled = true, bool logEvent = true);
|
2020-02-19 20:56:16 +01:00
|
|
|
|
Task DisableTwoFactorProviderAsync(User user, TwoFactorProviderType type,
|
|
|
|
|
IOrganizationService organizationService);
|
2020-02-28 16:23:19 +01:00
|
|
|
|
Task<bool> RecoverTwoFactorAsync(string email, string masterPassword, string recoveryCode,
|
|
|
|
|
IOrganizationService organizationService);
|
2017-05-31 15:54:32 +02:00
|
|
|
|
Task<string> GenerateUserTokenAsync(User user, string tokenProvider, string purpose);
|
2015-12-27 06:14:56 +01:00
|
|
|
|
Task<IdentityResult> DeleteAsync(User user);
|
2017-08-09 16:53:42 +02:00
|
|
|
|
Task<IdentityResult> DeleteAsync(User user, string token);
|
|
|
|
|
Task SendDeleteConfirmationAsync(string email);
|
2019-08-10 05:56:26 +02:00
|
|
|
|
Task<Tuple<bool, string>> SignUpPremiumAsync(User user, string paymentToken,
|
2020-06-18 01:49:27 +02:00
|
|
|
|
PaymentMethodType paymentMethodType, short additionalStorageGb, UserLicense license,
|
2020-06-18 16:41:55 +02:00
|
|
|
|
TaxInfo taxInfo);
|
2019-09-19 14:46:26 +02:00
|
|
|
|
Task IapCheckAsync(User user, PaymentMethodType paymentMethodType);
|
2017-08-14 18:08:57 +02:00
|
|
|
|
Task UpdateLicenseAsync(User user, UserLicense license);
|
2019-08-10 18:59:32 +02:00
|
|
|
|
Task<string> AdjustStorageAsync(User user, short storageAdjustmentGb);
|
2020-06-18 16:41:55 +02:00
|
|
|
|
Task ReplacePaymentMethodAsync(User user, string paymentToken, PaymentMethodType paymentMethodType, TaxInfo taxInfo);
|
2019-09-20 19:45:47 +02:00
|
|
|
|
Task CancelPremiumAsync(User user, bool? endOfPeriod = null, bool accountDelete = false);
|
2017-07-06 20:55:58 +02:00
|
|
|
|
Task ReinstatePremiumAsync(User user);
|
2019-08-10 05:56:26 +02:00
|
|
|
|
Task EnablePremiumAsync(Guid userId, DateTime? expirationDate);
|
|
|
|
|
Task EnablePremiumAsync(User user, DateTime? expirationDate);
|
2017-08-13 04:16:42 +02:00
|
|
|
|
Task DisablePremiumAsync(Guid userId, DateTime? expirationDate);
|
2017-08-16 23:08:20 +02:00
|
|
|
|
Task DisablePremiumAsync(User user, DateTime? expirationDate);
|
2017-08-13 04:16:42 +02:00
|
|
|
|
Task UpdatePremiumExpirationAsync(Guid userId, DateTime? expirationDate);
|
2020-08-18 23:00:21 +02:00
|
|
|
|
Task<UserLicense> GenerateLicenseAsync(User user, SubscriptionInfo subscriptionInfo = null,
|
|
|
|
|
int? version = null);
|
2018-04-17 14:10:17 +02:00
|
|
|
|
Task<bool> CheckPasswordAsync(User user, string password);
|
2018-12-19 17:48:36 +01:00
|
|
|
|
Task<bool> CanAccessPremium(ITwoFactorProvidersUser user);
|
2022-06-16 22:30:50 +02:00
|
|
|
|
Task<bool> HasPremiumFromOrganization(ITwoFactorProvidersUser user);
|
2018-12-19 17:48:36 +01:00
|
|
|
|
Task<bool> TwoFactorIsEnabledAsync(ITwoFactorProvidersUser user);
|
|
|
|
|
Task<bool> TwoFactorProviderIsEnabledAsync(TwoFactorProviderType provider, ITwoFactorProvidersUser user);
|
2020-08-26 20:12:04 +02:00
|
|
|
|
Task<string> GenerateSignInTokenAsync(User user, string purpose);
|
2020-11-10 21:15:29 +01:00
|
|
|
|
Task RotateApiKeyAsync(User user);
|
2021-08-11 18:44:30 +02:00
|
|
|
|
string GetUserName(ClaimsPrincipal principal);
|
2021-11-09 16:37:32 +01:00
|
|
|
|
Task SendOTPAsync(User user);
|
|
|
|
|
Task<bool> VerifyOTPAsync(User user, string token);
|
|
|
|
|
Task<bool> VerifySecretAsync(User user, string secret);
|
2022-04-28 18:14:09 +02:00
|
|
|
|
Task<bool> Needs2FABecauseNewDeviceAsync(User user, string deviceIdentifier, string grantType);
|
2022-06-06 19:52:50 +02:00
|
|
|
|
bool CanEditDeviceVerificationSettings(User user);
|
2015-12-09 04:57:38 +01:00
|
|
|
|
}
|