2015-12-08 22:57:38 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2016-05-19 19:10:24 -04:00
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
2017-03-08 21:45:08 -05:00
|
|
|
|
using Bit.Core.Models.Table;
|
2017-01-14 10:02:37 -05:00
|
|
|
|
using System.Security.Claims;
|
2017-06-07 14:14:34 -04:00
|
|
|
|
using Bit.Core.Enums;
|
|
|
|
|
|
using Bit.Core.Models;
|
2017-06-21 22:33:45 -04:00
|
|
|
|
using Bit.Core.Models.Business;
|
2015-12-08 22:57:38 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core.Services
|
|
|
|
|
|
{
|
|
|
|
|
|
public interface IUserService
|
|
|
|
|
|
{
|
2017-01-14 10:02:37 -05:00
|
|
|
|
Guid? GetProperUserId(ClaimsPrincipal principal);
|
2017-01-11 21:46:36 -05:00
|
|
|
|
Task<User> GetUserByIdAsync(string userId);
|
2016-05-21 17:16:22 -04:00
|
|
|
|
Task<User> GetUserByIdAsync(Guid userId);
|
2017-01-24 22:46:54 -05:00
|
|
|
|
Task<User> GetUserByPrincipalAsync(ClaimsPrincipal principal);
|
2017-01-14 10:02:37 -05:00
|
|
|
|
Task<DateTime> GetAccountRevisionDateByIdAsync(Guid userId);
|
2017-08-14 13:06:44 -04:00
|
|
|
|
Task SaveUserAsync(User user, bool push = false);
|
2018-05-24 16:53:07 -04:00
|
|
|
|
Task<IdentityResult> RegisterUserAsync(User user, string masterPassword, string token, Guid? orgUserId);
|
2020-08-13 17:30:10 -04:00
|
|
|
|
Task<IdentityResult> RegisterUserAsync(User user);
|
2015-12-08 22:57:38 -05:00
|
|
|
|
Task SendMasterPasswordHintAsync(string email);
|
2017-06-20 10:08:59 -04:00
|
|
|
|
Task SendTwoFactorEmailAsync(User user);
|
|
|
|
|
|
Task<bool> VerifyTwoFactorEmailAsync(User user, string token);
|
2017-06-21 22:33:45 -04:00
|
|
|
|
Task<U2fRegistration> StartU2fRegistrationAsync(User user);
|
2018-10-08 14:38:11 -04:00
|
|
|
|
Task<bool> DeleteU2fKeyAsync(User user, int id);
|
|
|
|
|
|
Task<bool> CompleteU2fRegistrationAsync(User user, int id, string name, string deviceResponse);
|
2017-07-01 23:20:19 -04:00
|
|
|
|
Task SendEmailVerificationAsync(User user);
|
|
|
|
|
|
Task<IdentityResult> ConfirmEmailAsync(User user, string token);
|
2015-12-08 22:57:38 -05:00
|
|
|
|
Task InitiateEmailChangeAsync(User user, string newEmail);
|
2017-05-31 09:54:32 -04:00
|
|
|
|
Task<IdentityResult> ChangeEmailAsync(User user, string masterPassword, string newEmail, string newMasterPassword,
|
|
|
|
|
|
string token, string key);
|
|
|
|
|
|
Task<IdentityResult> ChangePasswordAsync(User user, string masterPassword, string newMasterPassword, string key);
|
2020-08-12 17:03:09 -04:00
|
|
|
|
Task<IdentityResult> SetPasswordAsync(User user, string newMasterPassword, string key);
|
2018-08-14 15:30:04 -04:00
|
|
|
|
Task<IdentityResult> ChangeKdfAsync(User user, string masterPassword, string newMasterPassword, string key,
|
|
|
|
|
|
KdfType kdf, int kdfIterations);
|
2017-05-31 09:54:32 -04:00
|
|
|
|
Task<IdentityResult> UpdateKeyAsync(User user, string masterPassword, string key, string privateKey,
|
|
|
|
|
|
IEnumerable<Cipher> ciphers, IEnumerable<Folder> folders);
|
2015-12-08 22:57:38 -05:00
|
|
|
|
Task<IdentityResult> RefreshSecurityStampAsync(User user, string masterPasswordHash);
|
2017-06-07 14:14:34 -04:00
|
|
|
|
Task UpdateTwoFactorProviderAsync(User user, TwoFactorProviderType type);
|
2020-02-19 14:56:16 -05:00
|
|
|
|
Task DisableTwoFactorProviderAsync(User user, TwoFactorProviderType type,
|
|
|
|
|
|
IOrganizationService organizationService);
|
2020-02-28 10:23:19 -05:00
|
|
|
|
Task<bool> RecoverTwoFactorAsync(string email, string masterPassword, string recoveryCode,
|
|
|
|
|
|
IOrganizationService organizationService);
|
2017-05-31 09:54:32 -04:00
|
|
|
|
Task<string> GenerateUserTokenAsync(User user, string tokenProvider, string purpose);
|
2015-12-27 00:14:56 -05:00
|
|
|
|
Task<IdentityResult> DeleteAsync(User user);
|
2017-08-09 10:53:42 -04:00
|
|
|
|
Task<IdentityResult> DeleteAsync(User user, string token);
|
|
|
|
|
|
Task SendDeleteConfirmationAsync(string email);
|
2019-08-09 23:56:26 -04:00
|
|
|
|
Task<Tuple<bool, string>> SignUpPremiumAsync(User user, string paymentToken,
|
2020-06-17 19:49:27 -04:00
|
|
|
|
PaymentMethodType paymentMethodType, short additionalStorageGb, UserLicense license,
|
2020-06-18 10:41:55 -04:00
|
|
|
|
TaxInfo taxInfo);
|
2019-09-19 08:46:26 -04:00
|
|
|
|
Task IapCheckAsync(User user, PaymentMethodType paymentMethodType);
|
2017-08-14 12:08:57 -04:00
|
|
|
|
Task UpdateLicenseAsync(User user, UserLicense license);
|
2019-08-10 12:59:32 -04:00
|
|
|
|
Task<string> AdjustStorageAsync(User user, short storageAdjustmentGb);
|
2020-06-18 10:41:55 -04:00
|
|
|
|
Task ReplacePaymentMethodAsync(User user, string paymentToken, PaymentMethodType paymentMethodType, TaxInfo taxInfo);
|
2019-09-20 13:45:47 -04:00
|
|
|
|
Task CancelPremiumAsync(User user, bool? endOfPeriod = null, bool accountDelete = false);
|
2017-07-06 14:55:58 -04:00
|
|
|
|
Task ReinstatePremiumAsync(User user);
|
2019-08-09 23:56:26 -04:00
|
|
|
|
Task EnablePremiumAsync(Guid userId, DateTime? expirationDate);
|
|
|
|
|
|
Task EnablePremiumAsync(User user, DateTime? expirationDate);
|
2017-08-12 22:16:42 -04:00
|
|
|
|
Task DisablePremiumAsync(Guid userId, DateTime? expirationDate);
|
2017-08-16 17:08:20 -04:00
|
|
|
|
Task DisablePremiumAsync(User user, DateTime? expirationDate);
|
2017-08-12 22:16:42 -04:00
|
|
|
|
Task UpdatePremiumExpirationAsync(Guid userId, DateTime? expirationDate);
|
2020-08-18 17:00:21 -04:00
|
|
|
|
Task<UserLicense> GenerateLicenseAsync(User user, SubscriptionInfo subscriptionInfo = null,
|
|
|
|
|
|
int? version = null);
|
2018-04-17 08:10:17 -04:00
|
|
|
|
Task<bool> CheckPasswordAsync(User user, string password);
|
2018-12-19 11:48:36 -05:00
|
|
|
|
Task<bool> CanAccessPremium(ITwoFactorProvidersUser user);
|
|
|
|
|
|
Task<bool> TwoFactorIsEnabledAsync(ITwoFactorProvidersUser user);
|
|
|
|
|
|
Task<bool> TwoFactorProviderIsEnabledAsync(TwoFactorProviderType provider, ITwoFactorProvidersUser user);
|
2020-05-12 15:36:33 -04:00
|
|
|
|
Task<string> GenerateEnterprisePortalSignInTokenAsync(User user);
|
2015-12-08 22:57:38 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|