Due to a complicated oauth flow, we want to have new users active by default.
We see that in UserRegistrationManager line 80,
var isNewRegisteredUserActiveByDefault = await SettingManager.GetSettingValueAsync<bool>(AppSettings.UserManagement.IsNewRegisteredUserActiveByDefault);
We assumed that we could just set this in our Appsetting.json file like this.
"App": { "UserManagement": { "IsNewRegisteredUserActiveByDefault": "true" },
But we see that the value read by the GetSettingValueAsync is false, regarless of what we put in the json file.
To further compication this matter, we are using a differnet lauchprofile file. So instead of just using the Appsettings.json we are using Appsettings.xxxxxx.json.
We have also put the value in app.usermanagment.IsNewRegisteredUserActiveByDefault in the Appsettings.json file and the problem was still there.
When we change the value in the portals
Settings > UserManagment > New registered users are active by default.
it does work correctly.
Thoughts?
5 Answer(s)
-
0
It is read from database.
-
0
As you are working for ASPNETZERO to help answer questions in the forum, i ask.
Do you see your job to just put in some answer, any answer in each post, or are you here to help solve problems.
How does "it is read from database" help me?
Can you be more specific on how i can do this.
Last time i asked, you said "Its in SettingsManager", now you say its in the database.
Please write more than one partial sentence when answering questions.
I'm not the only person, who have commented on your terse style of answering questions.
-
0
@commondesk
SettingManager.GetSettingValueAsync(AppSettings.UserManagement.IsNewRegisteredUserActiveByDefault) Will not read setting from appsettings.json,See: https://aspnetboilerplate.com/Pages/Documents/Setting-Management
If you want to use the settings in appsettings.json, use asp net core configuration. https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-2.2
-
0
What we want to do is to set the default value of IsNewRegisteredUserActiveByDefault to True. Currently its default value is false.
I see now i was wrong in thinking that this value came from the Appsettings.json.
We see this value being read in UserRegistrationManager.cs line 80
var isNewRegisteredUserActiveByDefault = await SettingManager.GetSettingValueAsync<bool>(AppSettings.UserManagement.IsNewRegisteredUserActiveByDefault);
The terse @aaron said it in the database.
I now see that it could be set via
_settingManager.ChangeSettingForApplicationAsync(AppSettings.UserManagement.IsNewRegisteredUserActiveByDefault, "false");
But what im looking for is a way to set it when the system is created.
If i login via admin i can set it
Settings > UserManagment > New registered users are active by default, but thats not what im looking for.
-
0
You can provide default values (true) when you define them.
https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/Configuration/AppSettingProvider.cs#L84