Open Closed

How to Change SettingDefinition Scope #9320


User avatar
0
htavukcu created

Hi,

I’m trying to make the ExternalProviders and VerifyPasswordDuringExternalLogin settings in the Account module tenant-specific by setting the Providers property to "T". To achieve this, I’ve created a custom SettingProvider class that inherits from SettingDefinitionProvider, as described in the documentation.

Below is the relevant code snippet from the Define method where I attempt to modify these settings:

public override void Define(ISettingDefinitionContext context)
{        
    var accountExternalProviders = context.GetOrNull(AccountSettingNames.ExternalProviders);
    if (accountExternalProviders != null)
    {
        accountExternalProviders.Providers.Clear();
        accountExternalProviders.Providers.Add("T");
    }       

    var verifyPasswordDuringExternalLogin = context.GetOrNull(AccountSettingNames.VerifyPasswordDuringExternalLogin);
    if (verifyPasswordDuringExternalLogin != null)
    {
        verifyPasswordDuringExternalLogin.Providers.Clear();
        verifyPasswordDuringExternalLogin.Providers.Add("T");
    }

    //Define your own settings here. Example:
    //context.Add(new SettingDefinition(SuiteSettings.MySetting1));
}

However, I’m encountering an issue: when the application is initialized for the first time, the Define method is called and works correctly — the related settings in the SettingDefinition table are updated as expected. But when the Define method is called again, those settings are no longer present in the context, so I cannot apply the changes, and the previously updated Providers value is set to null in the database.

Could you please help me understand the reason behind this behavior and suggest a solution?

Thank you.


No answer yet!
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on June 13, 2025, 11:37