Open Closed

Email settings not visible for tenant #1622


User avatar
0
murat.yuceer created
  • ABP Framework version: v4.3.3
  • UI type: Blazor Server
  • DB provider: MongoDB
  • Tiered (MVC) or Identity Server Separated (Angular): no

Hi, How can i enabile email settings page for tenant?

When i login with host admin i see email settings

but when login with tenant admin its look like


6 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    This is by design.

    but you can change it in your application:

     public class YourProjectNamePermissionDefinitionProvider : PermissionDefinitionProvider
    {
        public override void Define(IPermissionDefinitionContext context)
        {
            ......
    
            var settingManagement = context.GetPermissionOrNull(SettingManagementPermissions.Emailing);
            settingManagement.MultiTenancySide = MultiTenancySides.Both;
       
            .....
        }
    
        .....
    }
    
    [Authorize(SettingManagementPermissions.Emailing)]
    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(EmailSettingsAppService), typeof(IEmailSettingsAppService))]
    public class MyEmailSettingsAppService : EmailSettingsAppService
    {
        public MyEmailSettingsAppService(ISettingManager settingManager) : base(settingManager)
        {
        }
    
        public override async Task<EmailSettingsDto> GetAsync()
        {
            return new EmailSettingsDto {
                SmtpHost = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Host),
                SmtpPort = Convert.ToInt32(await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Port)),
                SmtpUserName = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.UserName),
                SmtpPassword = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Password),
                SmtpDomain = await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Domain),
                SmtpEnableSsl = Convert.ToBoolean(await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.EnableSsl)),
                SmtpUseDefaultCredentials = Convert.ToBoolean(await SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.UseDefaultCredentials)),
                DefaultFromAddress = await SettingProvider.GetOrNullAsync(EmailSettingNames.DefaultFromAddress),
                DefaultFromDisplayName = await SettingProvider.GetOrNullAsync(EmailSettingNames.DefaultFromDisplayName),
            };
        }
    
        public override async Task UpdateAsync(UpdateEmailSettingsDto input)
        {
            if (!CurrentTenant.IsAvailable)
            {
                await SettingManager.SetGlobalAsync(EmailSettingNames.Smtp.Host, input.SmtpHost);
                await SettingManager.SetGlobalAsync(EmailSettingNames.Smtp.Port, input.SmtpPort.ToString());
                await SettingManager.SetGlobalAsync(EmailSettingNames.Smtp.UserName, input.SmtpUserName);
                await SettingManager.SetGlobalAsync(EmailSettingNames.Smtp.Password, input.SmtpPassword);
                await SettingManager.SetGlobalAsync(EmailSettingNames.Smtp.Domain, input.SmtpDomain);
                await SettingManager.SetGlobalAsync(EmailSettingNames.Smtp.EnableSsl, input.SmtpEnableSsl.ToString());
                await SettingManager.SetGlobalAsync(EmailSettingNames.Smtp.UseDefaultCredentials, input.SmtpUseDefaultCredentials.ToString().ToLowerInvariant());
                await SettingManager.SetGlobalAsync(EmailSettingNames.DefaultFromAddress, input.DefaultFromAddress);
                await SettingManager.SetGlobalAsync(EmailSettingNames.DefaultFromDisplayName, input.DefaultFromDisplayName);
            }
            else
            {
                await SettingManager.SetForCurrentTenantAsync(EmailSettingNames.Smtp.Host, input.SmtpHost);
                await SettingManager.SetForCurrentTenantAsync(EmailSettingNames.Smtp.Port, input.SmtpPort.ToString());
                await SettingManager.SetForCurrentTenantAsync(EmailSettingNames.Smtp.UserName, input.SmtpUserName);
                await SettingManager.SetForCurrentTenantAsync(EmailSettingNames.Smtp.Password, input.SmtpPassword);
                await SettingManager.SetForCurrentTenantAsync(EmailSettingNames.Smtp.Domain, input.SmtpDomain);
                await SettingManager.SetForCurrentTenantAsync(EmailSettingNames.Smtp.EnableSsl, input.SmtpEnableSsl.ToString());
                await SettingManager.SetForCurrentTenantAsync(EmailSettingNames.Smtp.UseDefaultCredentials, input.SmtpUseDefaultCredentials.ToString().ToLowerInvariant());
                await SettingManager.SetForCurrentTenantAsync(EmailSettingNames.DefaultFromAddress, input.DefaultFromAddress);
                await SettingManager.SetForCurrentTenantAsync(EmailSettingNames.DefaultFromDisplayName, input.DefaultFromDisplayName);
            }
        }
    
  • User Avatar
    0
    murat.yuceer created

    Thanks, i think this can be optional. Like language settings on feature

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Thanks, we will consider it.

  • User Avatar
    0
    murat.yuceer created

    Hi liangshiwei,

    I created fresh project with version 4.4.0, I did not see the following features

    Do you have plan add this to default Standard edition properties

    Enable account external settings Management Enable email settings Management

    Or

    When i select "Enable setting management" from features just show this settings for tenants

    Tenant should edit own Email Settings and Account External provider settings. These are important settings that distinguish between tenants.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    HI,

    See https://github.com/abpframework/abp/pull/9701

    It is available in 5.0

  • User Avatar
    0
    murat.yuceer created

    HI,

    See https://github.com/abpframework/abp/pull/9701

    It is available in 5.0

    Thanks, i hope you could add "External provider settings" too

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11