Merge branch 'develop' into feature/inifinite-scroll
This commit is contained in:
commit
ce79ef38d7
@ -134,42 +134,6 @@ public class UserServiceCache
|
||||
}
|
||||
}
|
||||
|
||||
[Scope]
|
||||
class ConfigureCachedUserService : IConfigureNamedOptions<CachedUserService>
|
||||
{
|
||||
internal readonly IOptionsSnapshot<EFUserService> Service;
|
||||
internal readonly UserServiceCache UserServiceCache;
|
||||
internal readonly CoreBaseSettings CoreBaseSettings;
|
||||
|
||||
public ConfigureCachedUserService(
|
||||
IOptionsSnapshot<EFUserService> service,
|
||||
UserServiceCache userServiceCache,
|
||||
CoreBaseSettings coreBaseSettings)
|
||||
{
|
||||
Service = service;
|
||||
UserServiceCache = userServiceCache;
|
||||
CoreBaseSettings = coreBaseSettings;
|
||||
}
|
||||
|
||||
public void Configure(string name, CachedUserService options)
|
||||
{
|
||||
Configure(options);
|
||||
options.Service = Service.Get(name);
|
||||
}
|
||||
|
||||
public void Configure(CachedUserService options)
|
||||
{
|
||||
options.Service = Service.Value;
|
||||
options.CoreBaseSettings = CoreBaseSettings;
|
||||
options.UserServiceCache = UserServiceCache;
|
||||
options.Cache = UserServiceCache.Cache;
|
||||
options.CacheUserInfoItem = UserServiceCache.CacheUserInfoItem;
|
||||
options.CacheUserPhotoItem = UserServiceCache.CacheUserPhotoItem;
|
||||
options.CacheGroupCacheItem = UserServiceCache.CacheGroupCacheItem;
|
||||
options.CacheUserGroupRefItem = UserServiceCache.CacheUserGroupRefItem;
|
||||
}
|
||||
}
|
||||
|
||||
[Scope]
|
||||
public class CachedUserService : IUserService, ICachedService
|
||||
{
|
||||
|
@ -66,38 +66,7 @@ public class CoreBaseSettings
|
||||
public bool DisableDocSpace => _disableDocSpace ?? (bool)(_disableDocSpace = string.Equals(Configuration["core:disableDocspace"], "true", StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
class ConfigureCoreSettings : IConfigureNamedOptions<CoreSettings>
|
||||
{
|
||||
private readonly IOptionsSnapshot<CachedTenantService> _tenantService;
|
||||
private readonly CoreBaseSettings _coreBaseSettings;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public ConfigureCoreSettings(
|
||||
IOptionsSnapshot<CachedTenantService> tenantService,
|
||||
CoreBaseSettings coreBaseSettings,
|
||||
IConfiguration configuration
|
||||
)
|
||||
{
|
||||
_tenantService = tenantService;
|
||||
_coreBaseSettings = coreBaseSettings;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public void Configure(string name, CoreSettings options)
|
||||
{
|
||||
Configure(options);
|
||||
options.TenantService = _tenantService.Get(name);
|
||||
}
|
||||
|
||||
public void Configure(CoreSettings options)
|
||||
{
|
||||
options.Configuration = _configuration;
|
||||
options.CoreBaseSettings = _coreBaseSettings;
|
||||
options.TenantService = _tenantService.Value;
|
||||
}
|
||||
}
|
||||
|
||||
[Scope(typeof(ConfigureCoreSettings))]
|
||||
[Scope]
|
||||
public class CoreSettings
|
||||
{
|
||||
public string BaseDomain
|
||||
|
@ -27,34 +27,6 @@
|
||||
namespace ASC.Core.Tenants;
|
||||
|
||||
[Scope]
|
||||
class ConfigureTenantUtil : IConfigureNamedOptions<TenantUtil>
|
||||
{
|
||||
private readonly IOptionsSnapshot<TenantManager> _tenantManager;
|
||||
private readonly TimeZoneConverter _timeZoneConverter;
|
||||
|
||||
public ConfigureTenantUtil(
|
||||
IOptionsSnapshot<TenantManager> tenantManager,
|
||||
TimeZoneConverter timeZoneConverter
|
||||
)
|
||||
{
|
||||
_tenantManager = tenantManager;
|
||||
_timeZoneConverter = timeZoneConverter;
|
||||
}
|
||||
|
||||
public void Configure(string name, TenantUtil options)
|
||||
{
|
||||
Configure(options);
|
||||
options._tenantManager = _tenantManager.Get(name);
|
||||
}
|
||||
|
||||
public void Configure(TenantUtil options)
|
||||
{
|
||||
options._timeZoneConverter = _timeZoneConverter;
|
||||
options._tenantManager = _tenantManager.Value;
|
||||
}
|
||||
}
|
||||
|
||||
[Scope(typeof(ConfigureTenantUtil))]
|
||||
public class TenantUtil
|
||||
{
|
||||
internal TenantManager _tenantManager;
|
||||
|
@ -33,20 +33,20 @@ public class EncryptionLoginProvider
|
||||
private readonly SecurityContext _securityContext;
|
||||
private readonly Signature _signature;
|
||||
private readonly InstanceCrypto _instanceCrypto;
|
||||
private readonly IOptionsSnapshot<AccountLinker> _snapshot;
|
||||
private readonly AccountLinker _accountLinker;
|
||||
|
||||
public EncryptionLoginProvider(
|
||||
ILogger<EncryptionLoginProvider> logger,
|
||||
SecurityContext securityContext,
|
||||
Signature signature,
|
||||
InstanceCrypto instanceCrypto,
|
||||
IOptionsSnapshot<AccountLinker> snapshot)
|
||||
AccountLinker accountLinker)
|
||||
{
|
||||
_logger = logger;
|
||||
_securityContext = securityContext;
|
||||
_signature = signature;
|
||||
_instanceCrypto = instanceCrypto;
|
||||
_snapshot = snapshot;
|
||||
_accountLinker = accountLinker;
|
||||
}
|
||||
|
||||
|
||||
@ -63,8 +63,7 @@ public class EncryptionLoginProvider
|
||||
Name = _instanceCrypto.Encrypt(keys)
|
||||
};
|
||||
|
||||
var linker = _snapshot.Get("webstudio");
|
||||
linker.AddLink(userId.ToString(), loginProfile);
|
||||
_accountLinker.AddLink(userId.ToString(), loginProfile);
|
||||
}
|
||||
|
||||
public string GetKeys()
|
||||
@ -74,8 +73,7 @@ public class EncryptionLoginProvider
|
||||
|
||||
public string GetKeys(Guid userId)
|
||||
{
|
||||
var linker = _snapshot.Get("webstudio");
|
||||
var profile = linker.GetLinkedProfiles(userId.ToString(), ProviderConstants.Encryption).FirstOrDefault();
|
||||
var profile = _accountLinker.GetLinkedProfiles(userId.ToString(), ProviderConstants.Encryption).FirstOrDefault();
|
||||
if (profile == null)
|
||||
{
|
||||
return null;
|
||||
|
@ -57,7 +57,7 @@ public class BoxApp : Consumer, IThirdPartyApp, IOAuthProvider
|
||||
private readonly SettingsManager _settingsManager;
|
||||
private readonly PersonalSettingsHelper _personalSettingsHelper;
|
||||
private readonly BaseCommonLinkUtility _baseCommonLinkUtility;
|
||||
private readonly IOptionsSnapshot<AccountLinker> _snapshot;
|
||||
private readonly AccountLinker _accountLinker;
|
||||
private readonly SetupInfo _setupInfo;
|
||||
private readonly TokenHelper _tokenHelper;
|
||||
private readonly DocumentServiceConnector _documentServiceConnector;
|
||||
@ -85,7 +85,7 @@ public class BoxApp : Consumer, IThirdPartyApp, IOAuthProvider
|
||||
SettingsManager settingsManager,
|
||||
PersonalSettingsHelper personalSettingsHelper,
|
||||
BaseCommonLinkUtility baseCommonLinkUtility,
|
||||
IOptionsSnapshot<AccountLinker> snapshot,
|
||||
AccountLinker accountLinker,
|
||||
SetupInfo setupInfo,
|
||||
TokenHelper tokenHelper,
|
||||
DocumentServiceConnector documentServiceConnector,
|
||||
@ -117,7 +117,7 @@ public class BoxApp : Consumer, IThirdPartyApp, IOAuthProvider
|
||||
_settingsManager = settingsManager;
|
||||
_personalSettingsHelper = personalSettingsHelper;
|
||||
_baseCommonLinkUtility = baseCommonLinkUtility;
|
||||
_snapshot = snapshot;
|
||||
_accountLinker = accountLinker;
|
||||
_setupInfo = setupInfo;
|
||||
_tokenHelper = tokenHelper;
|
||||
_documentServiceConnector = documentServiceConnector;
|
||||
@ -465,8 +465,7 @@ public class BoxApp : Consumer, IThirdPartyApp, IOAuthProvider
|
||||
|
||||
private bool CurrentUser(string boxUserId)
|
||||
{
|
||||
var linkedProfiles = _snapshot.Get("webstudio")
|
||||
.GetLinkedObjectsByHashId(HashHelper.MD5($"{ProviderConstants.Box}/{boxUserId}"));
|
||||
var linkedProfiles = _accountLinker.GetLinkedObjectsByHashId(HashHelper.MD5($"{ProviderConstants.Box}/{boxUserId}"));
|
||||
|
||||
return linkedProfiles.Any(profileId => Guid.TryParse(profileId, out var tmp) && tmp == _authContext.CurrentAccount.ID);
|
||||
}
|
||||
@ -474,8 +473,8 @@ public class BoxApp : Consumer, IThirdPartyApp, IOAuthProvider
|
||||
private void AddLinker(string boxUserId)
|
||||
{
|
||||
_logger.DebugBoxAppAddLinker(boxUserId);
|
||||
var linker = _snapshot.Get("webstudio");
|
||||
linker.AddLink(_authContext.CurrentAccount.ID.ToString(), boxUserId, ProviderConstants.Box);
|
||||
|
||||
_accountLinker.AddLink(_authContext.CurrentAccount.ID.ToString(), boxUserId, ProviderConstants.Box);
|
||||
}
|
||||
|
||||
private UserInfo GetUserInfo(Token token, out bool isNew)
|
||||
|
@ -63,7 +63,7 @@ public class GoogleDriveApp : Consumer, IThirdPartyApp, IOAuthProvider
|
||||
private readonly BaseCommonLinkUtility _baseCommonLinkUtility;
|
||||
private readonly FileUtility _fileUtility;
|
||||
private readonly FilesSettingsHelper _filesSettingsHelper;
|
||||
private readonly IOptionsSnapshot<AccountLinker> _snapshot;
|
||||
private readonly AccountLinker _accountLinker;
|
||||
private readonly SetupInfo _setupInfo;
|
||||
private readonly GoogleLoginProvider _googleLoginProvider;
|
||||
private readonly TokenHelper _tokenHelper;
|
||||
@ -97,7 +97,7 @@ public class GoogleDriveApp : Consumer, IThirdPartyApp, IOAuthProvider
|
||||
ILogger<GoogleDriveApp> logger,
|
||||
FileUtility fileUtility,
|
||||
FilesSettingsHelper filesSettingsHelper,
|
||||
IOptionsSnapshot<AccountLinker> snapshot,
|
||||
AccountLinker accountLinker,
|
||||
SetupInfo setupInfo,
|
||||
GoogleLoginProvider googleLoginProvider,
|
||||
TokenHelper tokenHelper,
|
||||
@ -111,9 +111,9 @@ public class GoogleDriveApp : Consumer, IThirdPartyApp, IOAuthProvider
|
||||
ICacheNotify<ConsumerCacheItem> cache,
|
||||
ConsumerFactory consumerFactory,
|
||||
IHttpClientFactory clientFactory,
|
||||
OAuth20TokenHelper oAuth20TokenHelper,
|
||||
RequestHelper requestHelper,
|
||||
ThirdPartySelector thirdPartySelector,
|
||||
OAuth20TokenHelper oAuth20TokenHelper,
|
||||
RequestHelper requestHelper,
|
||||
ThirdPartySelector thirdPartySelector,
|
||||
string name, int order, Dictionary<string, string> additional)
|
||||
: base(tenantManager, coreBaseSettings, coreSettings, configuration, cache, consumerFactory, name, order, additional)
|
||||
{
|
||||
@ -135,7 +135,7 @@ public class GoogleDriveApp : Consumer, IThirdPartyApp, IOAuthProvider
|
||||
_baseCommonLinkUtility = baseCommonLinkUtility;
|
||||
_fileUtility = fileUtility;
|
||||
_filesSettingsHelper = filesSettingsHelper;
|
||||
_snapshot = snapshot;
|
||||
_accountLinker = accountLinker;
|
||||
_setupInfo = setupInfo;
|
||||
_googleLoginProvider = googleLoginProvider;
|
||||
_tokenHelper = tokenHelper;
|
||||
@ -618,8 +618,7 @@ public class GoogleDriveApp : Consumer, IThirdPartyApp, IOAuthProvider
|
||||
|
||||
private bool CurrentUser(string googleId)
|
||||
{
|
||||
var linker = _snapshot.Get("webstudio");
|
||||
var linkedProfiles = linker.GetLinkedObjectsByHashId(HashHelper.MD5($"{ProviderConstants.Google}/{googleId}"));
|
||||
var linkedProfiles = _accountLinker.GetLinkedObjectsByHashId(HashHelper.MD5($"{ProviderConstants.Google}/{googleId}"));
|
||||
|
||||
return linkedProfiles.Any(profileId => Guid.TryParse(profileId, out var tmp) && tmp == _authContext.CurrentAccount.ID);
|
||||
}
|
||||
@ -627,8 +626,8 @@ public class GoogleDriveApp : Consumer, IThirdPartyApp, IOAuthProvider
|
||||
private void AddLinker(string googleUserId)
|
||||
{
|
||||
_logger.DebugGoogleDriveApAddLinker(googleUserId);
|
||||
var linker = _snapshot.Get("webstudio");
|
||||
linker.AddLink(_authContext.CurrentAccount.ID.ToString(), googleUserId, ProviderConstants.Google);
|
||||
|
||||
_accountLinker.AddLink(_authContext.CurrentAccount.ID.ToString(), googleUserId, ProviderConstants.Google);
|
||||
}
|
||||
|
||||
private UserInfo GetUserInfo(Token token, out bool isNew)
|
||||
|
@ -30,7 +30,7 @@ namespace ASC.People.Api;
|
||||
|
||||
public class ThirdpartyController : ApiControllerBase
|
||||
{
|
||||
private readonly IOptionsSnapshot<AccountLinker> _accountLinker;
|
||||
private readonly AccountLinker _accountLinker;
|
||||
private readonly CookiesManager _cookiesManager;
|
||||
private readonly CoreBaseSettings _coreBaseSettings;
|
||||
private readonly DisplayUserSettingsHelper _displayUserSettingsHelper;
|
||||
@ -52,7 +52,7 @@ public class ThirdpartyController : ApiControllerBase
|
||||
private readonly StudioNotifyService _studioNotifyService;
|
||||
|
||||
public ThirdpartyController(
|
||||
IOptionsSnapshot<AccountLinker> accountLinker,
|
||||
AccountLinker accountLinker,
|
||||
CookiesManager cookiesManager,
|
||||
CoreBaseSettings coreBaseSettings,
|
||||
DisplayUserSettingsHelper displayUserSettingsHelper,
|
||||
@ -104,7 +104,7 @@ public class ThirdpartyController : ApiControllerBase
|
||||
|
||||
if (_authContext.IsAuthenticated)
|
||||
{
|
||||
linkedAccounts = _accountLinker.Get("webstudio").GetLinkedProfiles(_authContext.CurrentAccount.ID.ToString());
|
||||
linkedAccounts = _accountLinker.GetLinkedProfiles(_authContext.CurrentAccount.ID.ToString());
|
||||
}
|
||||
|
||||
fromOnly = string.IsNullOrWhiteSpace(fromOnly) ? string.Empty : fromOnly.ToLower();
|
||||
@ -148,7 +148,7 @@ public class ThirdpartyController : ApiControllerBase
|
||||
|
||||
if (string.IsNullOrEmpty(profile.AuthorizationError))
|
||||
{
|
||||
GetLinker().AddLink(_securityContext.CurrentAccount.ID.ToString(), profile);
|
||||
_accountLinker.AddLink(_securityContext.CurrentAccount.ID.ToString(), profile);
|
||||
_messageService.Send(MessageAction.UserLinkedSocialAccount, GetMeaningfulProviderName(profile.Provider));
|
||||
}
|
||||
else
|
||||
@ -204,7 +204,7 @@ public class ThirdpartyController : ApiControllerBase
|
||||
SaveContactImage(userID, thirdPartyProfile.Avatar);
|
||||
}
|
||||
|
||||
GetLinker().AddLink(userID.ToString(), thirdPartyProfile);
|
||||
_accountLinker.AddLink(userID.ToString(), thirdPartyProfile);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -232,7 +232,7 @@ public class ThirdpartyController : ApiControllerBase
|
||||
[HttpDelete("thirdparty/unlinkaccount")]
|
||||
public void UnlinkAccount(string provider)
|
||||
{
|
||||
GetLinker().RemoveProvider(_securityContext.CurrentAccount.ID.ToString(), provider);
|
||||
_accountLinker.RemoveProvider(_securityContext.CurrentAccount.ID.ToString(), provider);
|
||||
|
||||
_messageService.Send(MessageAction.UserUnlinkedSocialAccount, GetMeaningfulProviderName(provider));
|
||||
}
|
||||
@ -262,11 +262,6 @@ public class ThirdpartyController : ApiControllerBase
|
||||
return _userManagerWrapper.AddUser(userInfo, passwordHash, true, true, isVisitor, fromInviteLink);
|
||||
}
|
||||
|
||||
private AccountLinker GetLinker()
|
||||
{
|
||||
return _accountLinker.Get("webstudio");
|
||||
}
|
||||
|
||||
private void SaveContactImage(Guid userID, string url)
|
||||
{
|
||||
using (var memstream = new MemoryStream())
|
||||
|
@ -46,7 +46,7 @@ public class AuthenticationController : ControllerBase
|
||||
private readonly SetupInfo _setupInfo;
|
||||
private readonly MessageService _messageService;
|
||||
private readonly ProviderManager _providerManager;
|
||||
private readonly IOptionsSnapshot<AccountLinker> _accountLinker;
|
||||
private readonly AccountLinker _accountLinker;
|
||||
private readonly CoreBaseSettings _coreBaseSettings;
|
||||
private readonly PersonalSettingsHelper _personalSettingsHelper;
|
||||
private readonly StudioNotifyService _studioNotifyService;
|
||||
@ -80,7 +80,7 @@ public class AuthenticationController : ControllerBase
|
||||
SetupInfo setupInfo,
|
||||
MessageService messageService,
|
||||
ProviderManager providerManager,
|
||||
IOptionsSnapshot<AccountLinker> accountLinker,
|
||||
AccountLinker accountLinker,
|
||||
CoreBaseSettings coreBaseSettings,
|
||||
PersonalSettingsHelper personalSettingsHelper,
|
||||
StudioNotifyService studioNotifyService,
|
||||
@ -534,8 +534,7 @@ public class AuthenticationController : ControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
var linker = _accountLinker.Get("webstudio");
|
||||
linker.AddLink(userInfo.Id.ToString(), loginProfile);
|
||||
_accountLinker.AddLink(userInfo.Id.ToString(), loginProfile);
|
||||
|
||||
return userInfo;
|
||||
}
|
||||
@ -581,7 +580,7 @@ public class AuthenticationController : ControllerBase
|
||||
return false;
|
||||
}
|
||||
|
||||
var linkedProfiles = _accountLinker.Get("webstudio").GetLinkedObjectsByHashId(hashId);
|
||||
var linkedProfiles = _accountLinker.GetLinkedObjectsByHashId(hashId);
|
||||
var tmp = Guid.Empty;
|
||||
if (linkedProfiles.Any(profileId => Guid.TryParse(profileId, out tmp) && _userManager.UserExists(tmp)))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user