Hi. I send some detail info to your info@aspnetzero.
We set all our server side config data from azures enviromental settings. But for the summarise: App:ClientRootAddress -> https://{TENANCY_NAME}.oursite.net App:WebSiteRootAddress -> https://{TENANCY_NAME}.oursite.net
The request url is same: tenantname.oursite.net
Yes, tenant name is "ABC" and in url it is "abc". We are able to select it when {TENANCY_NAME} is not being used.
Hi. I have tried to set up our merged Angular project to work with subdomains but if I go to url tenantname.oursite.net, it will open the site, but it tryes to login to the HOST, not Tenant. So the tenant name part is being ignored in url. Does anyone have a clue where we have gone wrong?
We have put Angular project src/assets/appconfig.production.json "remoteServiceBaseUrl": "https://{TENANCY_NAME}.oursite.net", "appBaseUrl": "https://{TENANCY_NAME}.oursite.net",
and I have tried to set appsettings.production.json WebSiteRootAddress and ClientRootAddress same way.
In the documents [https://aspnetzero.com/Documents/Development-Guide-Angular#configuration])
Tenancy name can also be configured for remoteServiceBaseUrl as similar but when it is necessary?
If I follow these instructions [https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=10132&hilit=TENANCY_NAME&start=10]) I should only set appBaseUrl and ClientRootAddress with TENANCY_NAME placeholder.
and here [https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=10422&hilit=wwwroot+dist#p24966]) is suggested that I should put placeholder on every url..
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 = "...";