Personal: optimization

This commit is contained in:
pavelbannov 2021-08-12 14:00:05 +03:00
parent ef4f0c9788
commit 163e73ef4a
2 changed files with 4 additions and 32 deletions

View File

@ -246,7 +246,9 @@ namespace ASC.Core.Caching
}
public UserInfo GetUser(int tenant, Guid id)
{
{
if (id.Equals(Guid.Empty)) return null;
if (CoreBaseSettings.Personal)
{
return GetUserForPersonal(tenant, id);
@ -279,7 +281,7 @@ namespace ASC.Core.Caching
/// <returns></returns>
private UserInfo GetUserForPersonal(int tenant, Guid id)
{
if (!CoreBaseSettings.Personal) return GetUser(tenant, id);
if (!CoreBaseSettings.Personal) return GetUser(tenant, id);
var key = UserServiceCache.GetUserCacheKeyForPersonal(tenant, id);
var user = Cache.Get<UserInfo>(key);

View File

@ -286,36 +286,6 @@ namespace ASC.Core
}
}
return findUsers.ToArray();
}
public UserInfo SaveUserInfo(UserInfo u)
{
if (IsSystemUser(u.ID)) return SystemUsers[u.ID];
if (u.ID == Guid.Empty) PermissionContext.DemandPermissions(Constants.Action_AddRemoveUser);
else PermissionContext.DemandPermissions(new UserSecurityProvider(u.ID), Constants.Action_EditUser);
if (Constants.MaxEveryoneCount <= GetUsersByGroup(Constants.GroupEveryone.ID).Length)
{
throw new TenantQuotaException("Maximum number of users exceeded");
}
if (u.Status == EmployeeStatus.Active)
{
var q = TenantManager.GetTenantQuota(Tenant.TenantId);
if (q.ActiveUsers < GetUsersByGroup(Constants.GroupUser.ID).Length)
{
throw new TenantQuotaException(string.Format("Exceeds the maximum active users ({0})", q.ActiveUsers));
}
}
if (u.Status == EmployeeStatus.Terminated && u.ID == TenantManager.GetCurrentTenant().OwnerId)
{
throw new InvalidOperationException("Can not disable tenant owner.");
}
var newUser = UserService.SaveUser(Tenant.TenantId, u);
return newUser;
}
public UserInfo SaveUserInfo(UserInfo u, bool isVisitor = false)