Set invite users to false if deny local login is true (#16043)
This commit is contained in:
@@ -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;
|
||||
@@ -25,6 +26,7 @@ public class UserPresentationFactory : IUserPresentationFactory
|
||||
private readonly IAbsoluteUrlBuilder _absoluteUrlBuilder;
|
||||
private readonly IEmailSender _emailSender;
|
||||
private readonly IPasswordConfigurationPresentationFactory _passwordConfigurationPresentationFactory;
|
||||
private readonly IBackOfficeExternalLoginProviders _externalLoginProviders;
|
||||
private readonly SecuritySettings _securitySettings;
|
||||
|
||||
public UserPresentationFactory(
|
||||
@@ -36,7 +38,8 @@ public class UserPresentationFactory : IUserPresentationFactory
|
||||
IAbsoluteUrlBuilder absoluteUrlBuilder,
|
||||
IEmailSender emailSender,
|
||||
IPasswordConfigurationPresentationFactory passwordConfigurationPresentationFactory,
|
||||
IOptionsSnapshot<SecuritySettings> securitySettings)
|
||||
IOptionsSnapshot<SecuritySettings> securitySettings,
|
||||
IBackOfficeExternalLoginProviders externalLoginProviders)
|
||||
{
|
||||
_entityService = entityService;
|
||||
_appCaches = appCaches;
|
||||
@@ -45,6 +48,7 @@ public class UserPresentationFactory : IUserPresentationFactory
|
||||
_userGroupPresentationFactory = userGroupPresentationFactory;
|
||||
_emailSender = emailSender;
|
||||
_passwordConfigurationPresentationFactory = passwordConfigurationPresentationFactory;
|
||||
_externalLoginProviders = externalLoginProviders;
|
||||
_securitySettings = securitySettings.Value;
|
||||
_absoluteUrlBuilder = absoluteUrlBuilder;
|
||||
}
|
||||
@@ -130,7 +134,8 @@ public class UserPresentationFactory : IUserPresentationFactory
|
||||
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(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user