you can set it in your project.
yes I can. My only consern is that if it is being used somewhere before my set command takes plase, it may cause encrypt/decrupt failures for the "before my set commad" encryptions.
ยจ@alper thank you for your patience, i still need more info :D maybe i should clafiry my situation more.
I have action where a background job is created to send email with data. Entity is being created by known user, so I am able to get tenant id and user id for parameters.
At background job, I need to translate email by the user who hit the action. At background job, there is active user, so I tried to use: using (_session.Use(userId, tenantId)) { // Get setting value here... } That seemed to work for me when locally debuggin but now I did some more investigations.
I created this code to the background job:
var usersLanguage = _settingManager.GetSettingValueForUser(LocalizationSettingNames.DefaultLanguage, tenantId, userId);
string text;
using (_session.Use(tenantId, userId))
{
text = L("Error");
}
string result;
if (text.Equals("Error!"))
result = "Localization is english";
else if (text.Equals("VIRHE!"))
result = "Localization is finnish, default";
else
result = "This was not expected: " + text;
and I tried to run it with two users: User 1 => language is set to "fi" User 2 => language is set to "en"
With both users, usersLanguage was correct ("fi" and "en"), but for some reason, result was on both "Localization is finnish, default". So it seems that it was using default all the time. My debugging server has default fi, so I thought that this was working because I have fi set to be my user language. In our staging server, there default language was "en" so emails were allways translated with english language.
So to summarise,
using (_session.Use(tenantId, userId))
{
text = L("Error");
}
is not working as expected when used in background job? Can you verify this?
Yes, but that does NOT <ins>CHANGE</ins>SimpleStringCipher.DefaultPassPhrase, which is being used for example for Tenant specific dbconnection string encrypting and decrypting TenantManager: ConnectionString = connectionString.IsNullOrWhiteSpace() ? null : SimpleStringCipher.Instance.Encrypt(connectionString),
[https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp/Runtime/Security/SimpleStringCipher_NetStandard.cs#L48]) Lines 48, 68 and 109.
And there at line 26: > /// It's recommented to set to another value for security.
So the question still remains: is there somewhere line in Zero module:
SimpleStringCipher.DefaultPassPhrase = AppConsts.DefaultPassPhrase
or should I add it for my self to somewhere?
<cite>alper: </cite> You can add a new property <UserLanguage> to the user entity and use that field for user's language.
okay, but where should I take the active localization value?
and at the backgroud job, how I can set localization to use that provided setting?
@alper
The other one is in the ABP framework, Zero overrides that.
Where and when it is being overrided?
I changed AppConst DefaultPassPhrase to static string and set it at Application modules PreInitialize method. I also put breakpoint to getter so I was able to see if it it was being used before it was initialized.
//public const string DefaultPassPhrase = "old code";
private static string _defaultPassPhrase;
public static string DefaultPassPhrase { get
{
if (_defaultPassPhrase == null)
throw new AbpException("DefaultPassPhrase was not set before getter was being used!");
return _defaultPassPhrase;
}
set
{
_defaultPassPhrase = value;
}
}
I also set breakpoint to my TenantCache extension object, where SimpleStringCipher.Instance.Decrypt is being used and noticed that there SimpleStringCipher's DefaultPassPhrase was not changed. It still was the one, you recommend to change??
It seems that user passwords are not hashed with SimpleStringCipher so I can forget that.
Main concern is for the Q1 that if I but it at Modules PreInitialize(), is it being used before my change takes effect?
Q3: Why there is different DefaultPassPhrase at templates Application.Shared -> AppConsts class?
Yes it works, if user has setting which tells what users preferred language is. But when background task is running, and there is no such setting (language is determined by other way) Session provides default language. So session setting will not work allways.
Is there a way, that I can get users language when creating background task, and set that language to be active from task parameters when background task is running?
Hi @alper Yes I am going to use enviromental variable, but I need help with these questions:
SimpleStringCipher.DefaultPassPhrase = "...";
@maharatha were you able to make it enviromental variable? I also was thinking this since I don't wan't passphrase to be visible in project files.
I was wondering where I should overwrite SimpleStringCipher DefaultPassPhrase so the startup value is not being used and how to handle Seed HostRoleAndUserCreator where Host admin user is created and it is given encrypted Password?
I think we have latest codes. It is just that now finnish users need to select FLE Standard Time. I didn't know that without googling, so I doubt that normal user is not able to figure it out either. I think that there was better options before updating.. We propably need to put a link to [https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones]) so users can check it out if they are unsure as I was.