In part of the documentation it is mentioned that the tenant 1 is created and will be used with default.
What is the user administrator used with tenant null and tenant null?
No, not yet solved. I'm temporarily recording the selected id in a field within the Users entity which I've extended, but this is costly in terms of performance to the database.
I'll send parts of my source, I think it's easier. MySession Class
public class MySession : IAbpSession, ITransientDependency
{
public IAbpSession _AbpSession;
public MySession(IAbpSession AbpSession)
{
_AbpSession=AbpSession;
}
public int? ImpersonatorTenantId
{
get { return _AbpSession.ImpersonatorTenantId; }
}
public long? ImpersonatorUserId
{
get { return _AbpSession.ImpersonatorUserId; }
}
public Abp.MultiTenancy.MultiTenancySides MultiTenancySide
{
get { return _AbpSession.MultiTenancySide; }
}
public int? TenantId
{
get { return _AbpSession.TenantId; }
}
public long? UserId
{
get { return _AbpSession.UserId; }
}
public string FormaturaSelecionada
{
get
{
var claimsPrincipal = Thread.CurrentPrincipal as ClaimsPrincipal;
if (claimsPrincipal == null)
{
return null;
}
var formaturaClaim = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == "FormaturaAtual");
if (formaturaClaim == null || string.IsNullOrEmpty(formaturaClaim.Value))
{
return null;
}
return formaturaClaim.Value;
}
set
{
var claimsPrincipal = Thread.CurrentPrincipal as ClaimsPrincipal;
if (claimsPrincipal == null)
{
throw new Exception("erro");
}
claimsPrincipal.Identities.First().AddClaim(new Claim("FormaturaAtual", value));
}
}
}
The user when selecting the Graduation, through the screen below, calls the controler FormaturaSelect, sending the new ID which must be set in the session variable.
public async Task<JsonResult> FormaturaSelect(int id, string returnUrl = "")
{
Debug.WriteLine(string.Format("----Check selected value ----"));
Debug.WriteLine(string.Format("Step 1: Current Value in _mySession = [{0}]", _mySession.FormaturaSelecionada));
Debug.WriteLine(string.Format("Step 2: Add value id= [{0}]", id));
_mySession.FormaturaSelecionada = id.ToString();
Debug.WriteLine(string.Format("Step 3: Current Value in _mySession = [{0}]", _mySession.FormaturaSelecionada));
//continue...
}
I put several debugs in the code, below the results. First execution: ----Check selected value ---- Step 1: Current Value in _mySession = [] Step 2: Add value id= [1] Step 3: Current Value in _mySession = [1]
Second executionL ----Check selected value ---- Step 1: Current Value in _mySession = [] Step 2: Add value id= [2] Step 3: Current Value in _mySession = [2]
The value between the two requests is lost. But it can be seen that it adds to the current Claim
When I use the property after a Login, everything happens perfectly.
LoginResult.Identity.AddClaim (new Claim ("Company", CompanyId.ToString ()));
I tried to use _userManager.AddClaim, in another part of the code, where the user can select another company related to it, it starts to add the values in the table AbpUserClaims, but recording the wrong information.
Claim myClaim = new Claim ("type", "value");
_userManager.AddClaim (_AbpSession.GetUserId (), myClaim);
ClainType receives the value, and the ClaimValue is null, generating problems for the next user login.
What is the correct way to do this operation?
Thank you, that's exactly what I needed!
I'll try to explain my problem in more detail, it may be that Abp can help me using some already existing structure that, I'm not seeing.
I have 3 types of users that will use the platform:
The use of the tenant was limited to the use by the accountants, since they must see 1 or more companies, but without being able to see all, that is, they can not be admin, just me.
For this, I created a structure Companies vs. Users, thus controlling who has access to a particular company.
The user, when entering the system, selects which company wants to see the data, this way I force the filter and I only bring the data referring to the company that he selected during that session.
This is the question in relation to the above question, how to know and filter the data of which company the user selected.
I have a very simple question, but I do not know how to proceed. I need to identify in the user which company he belongs to (company is not a tenant) I tried using session, implementing a new class with a new property
IocManager.Register<IAbpSession, MySession>(DependencyLifeStyle.Transient);
public class MySession : IAbpSession, ITransientDependency
{
public IAbpSession _AbpSession;
public int? CurrentCompany { get; set; }
public MySession()
{
}
public int? ImpersonatorTenantId
{
get { return _AbpSession.ImpersonatorTenantId; }
}
...
However this way I can not access the properties via DI.
Also I have not seen an easy way to change the User class and always record the company which the user is logged in.
Can someone help me?
I managed to run, implementing Api version of swagger without using ABPWebApi (). Now I have the error Not supported by Swagger 2.0: Multiple operations with path 'api / AbpServiceProxies' and method 'GET'.
Already tried removing the .WithConventionalVerbs () of Configuration.Modules.AbpWebApi (). DynamicApiControllerBuilder, but still without success.
I try to enable Swagger using the example of documentation (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Swagger-UI-Integration">http://www.aspnetboilerplate.com/Pages/ ... ntegration</a> ), however there is no reference to the .EnableSwagger in HttpConfiguration.
Erro 1 'System.Web.Http.HttpConfiguration' does not contain a definition for 'EnableSwagger' and no extension method 'EnableSwagger' accepting a first argument of type 'System.Web.Http.HttpConfiguration' could be found (are you missing a using directive or an assembly reference?) XXXXXX\F.WebApi\Api\FWebApiModule.cs 31 64 F.WebApi
What can it be?
Doubts regarding tenant and organization unit.
I am starting a new application, and would like to implement the zero module, I have doubts about using some tenant or organization Unit, I will explain.
A student to log in the application must enter a study group. All information are related to the study group. (At this point I assumed that the study group = tenant)
This student can invite other students to the same group (adding users to the tenant)
This student can participate in more than one study group (eg Group of Physics, Mathematics Group, Chemical Group)
However, there is another type of person accompanying the group as a moderator, where he can see and run only a few functions.
At this point that generated the confusion, one User can view the information from various tenants without having to keep changing session?
(Ex: The moderator wants to know the amount of files uploaded by study group) (Ex2: The moderator manages 2 groups (Physics and Mathematics) want to know the notes of a particular student who participates in study groups he moderates)
An important point that 95% of students only belong to one group of studies, so set the study group as a tenant.
Any suggestion? :?: :?: :?: