Skip to content

Commit

Permalink
fix Bug 66846
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelbannov committed Mar 12, 2024
1 parent 8b1e3fe commit 7ace48a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
14 changes: 10 additions & 4 deletions web/ASC.Web.Api/Api/Settings/SecurityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ public class SecurityController(TenantManager tenantManager,
WebItemManager webItemManager,
WebItemManagerSecurity webItemManagerSecurity,
DisplayUserSettingsHelper displayUserSettingsHelper,
EmployeeDtoHelper employeeWraperHelper,
EmployeeDtoHelper employeeWrapperHelper,
MessageTarget messageTarget,
IMemoryCache memoryCache,
IMapper mapper,
IHttpContextAccessor httpContextAccessor)
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration)
: BaseSettingsController(apiContext, memoryCache, webItemManager, httpContextAccessor)
{
/// <summary>
Expand Down Expand Up @@ -85,7 +86,7 @@ public async IAsyncEnumerable<SecurityDto> GetWebItemSecurityInfo([FromQuery] IE

foreach (var e in i.Users)
{
s.Users.Add(await employeeWraperHelper.GetAsync(e));
s.Users.Add(await employeeWrapperHelper.GetAsync(e));
}

yield return s;
Expand Down Expand Up @@ -167,6 +168,11 @@ public async Task<PasswordSettings> UpdatePasswordSettingsAsync(PasswordSettings

var userPasswordSettings = await settingsManager.LoadAsync<PasswordSettings>();

if (!PasswordSettings.CheckLengthInRange(configuration, inDto.MinLength))
{
throw new ArgumentException(nameof(inDto.MinLength));
}

userPasswordSettings.MinLength = inDto.MinLength;
userPasswordSettings.UpperCase = inDto.UpperCase;
userPasswordSettings.Digits = inDto.Digits;
Expand Down Expand Up @@ -308,7 +314,7 @@ public async IAsyncEnumerable<EmployeeDto> GetProductAdministrators(Guid product

foreach (var a in admins)
{
yield return await employeeWraperHelper.GetAsync(a);
yield return await employeeWrapperHelper.GetAsync(a);
}
}

Expand Down
10 changes: 10 additions & 0 deletions web/ASC.Web.Core/Utility/PasswordSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,14 @@ public PasswordSettings GetDefault()

return def;
}

public static bool CheckLengthInRange(IConfiguration configuration, int length)
{
if (!int.TryParse(configuration["web:password:min"], out var defaultMinLength))
{
defaultMinLength = 0;
}

return length >= defaultMinLength && length <= MaxLength;
}
}

0 comments on commit 7ace48a

Please sign in to comment.