Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set invite users to false if deny local login is true #16043

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,6 @@
using Umbraco.Cms.Api.Management.Routing;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Api.Management.Security;
using Umbraco.Cms.Api.Management.ViewModels.User;
using Umbraco.Cms.Api.Management.ViewModels.User.Current;
using Umbraco.Cms.Core.Cache;
Expand All @@ -25,6 +26,7 @@
private readonly IAbsoluteUrlBuilder _absoluteUrlBuilder;
private readonly IEmailSender _emailSender;
private readonly IPasswordConfigurationPresentationFactory _passwordConfigurationPresentationFactory;
private readonly IBackOfficeExternalLoginProviders _externalLoginProviders;
private readonly SecuritySettings _securitySettings;

public UserPresentationFactory(
Expand All @@ -36,15 +38,17 @@
IAbsoluteUrlBuilder absoluteUrlBuilder,
IEmailSender emailSender,
IPasswordConfigurationPresentationFactory passwordConfigurationPresentationFactory,
IOptionsSnapshot<SecuritySettings> securitySettings)
IOptionsSnapshot<SecuritySettings> securitySettings,
IBackOfficeExternalLoginProviders externalLoginProviders)
{
_entityService = entityService;
_appCaches = appCaches;
_mediaFileManager = mediaFileManager;
_imageUrlGenerator = imageUrlGenerator;
_userGroupPresentationFactory = userGroupPresentationFactory;
_emailSender = emailSender;
_passwordConfigurationPresentationFactory = passwordConfigurationPresentationFactory;
_externalLoginProviders = externalLoginProviders;

Check notice on line 51 in src/Umbraco.Cms.Api.Management/Factories/UserPresentationFactory.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v14/dev)

ℹ Getting worse: Constructor Over-Injection

UserPresentationFactory increases from 9 to 10 arguments, threshold = 5. This constructor has too many arguments, indicating an object with low cohesion or missing function argument abstraction. Avoid adding more arguments.
_securitySettings = securitySettings.Value;
_absoluteUrlBuilder = absoluteUrlBuilder;
}
Expand Down Expand Up @@ -130,7 +134,8 @@
public Task<UserConfigurationResponseModel> CreateUserConfigurationModelAsync() =>
Task.FromResult(new UserConfigurationResponseModel
{
CanInviteUsers = _emailSender.CanSendRequiredEmail(),
// You should not be able to invite users if any providers has deny local login set.
CanInviteUsers = _emailSender.CanSendRequiredEmail() && _externalLoginProviders.HasDenyLocalLogin() is false,
PasswordConfiguration = _passwordConfigurationPresentationFactory.CreatePasswordConfigurationResponseModel(),
});

Expand Down