我将asp.net样板用作Web项目,并将后端用于移动应用程序。
该应用是多租户。
我有一种验证移动访问代码的方法。
这是代码
// See this address is not already in the symbol table fake up an
// nlist for it.
if (!found) {
NMSymbol F = {};
F.Name = "<redacted function X>";
F.Address = FoundFns[f] + BaseSegmentAddress;
F.Size = 0;
// There is no symbol in the nlist symbol table for this so we set
// Sym effectivly to null and the rest of code in here must test for
// it and not do things like Sym.getFlags() for it.
F.Sym = BasicSymbolRef();
F.SymFlags = 0;
F.NType = MachO::N_SECT;
F.NSect = 0;
StringRef SegmentName = StringRef();
StringRef SectionName = StringRef();
for (const SectionRef &Section : MachO->sections()) {
Section.getName(SectionName);
SegmentName = MachO->getSectionFinalSegmentName(
Section.getRawDataRefImpl());
F.NSect++;
if (F.Address >= Section.getAddress() &&
F.Address < Section.getAddress() + Section.getSize()) {
F.Section = Section;
break;
}
}
if (SegmentName == "__TEXT" && SectionName == "__text")
F.TypeChar = 't';
else if (SegmentName == "__DATA" && SectionName == "__data")
F.TypeChar = 'd';
else if (SegmentName == "__DATA" && SectionName == "__bss")
F.TypeChar = 'b';
else
F.TypeChar = 's';
F.NDesc = 0;
F.IndirectName = StringRef();
SymbolList.push_back(F);
if (FoundFns[f] == lc_main_offset)
FOS << "<redacted LC_MAIN>";
else
FOS << "<redacted function " << f << ">";
FOS << '\0';
FunctionStartsAdded++;
}
但是此行[AllowAnonymous]
[ProducesResponseType(typeof(UserDataModel), 200)]
[ProducesResponseType(401)]
[HttpPost]
public async Task<IActionResult> ValidateMobileAccessCode(MobileInvitationCodeInput input)
{
var tenant = await _tenantRepository.GetAll().Where(x => x.Id == AbpSession.TenantId).FirstOrDefaultAsync();
var userId = await _userMobileAccessCodeService.ValidateCodeAndGetUserIdAsync(input.CodeValue);
if (userId == null)
{
return Unauthorized();
}
var user = await _userManager.GetUserOrNullAsync(new UserIdentifier(AbpSession.TenantId, userId.Value));
return Ok(new UserDataModel
{
UserId = userId.Value,
CodeValue = input.CodeValue,
Name = user.FullName,
EmailAddress = user.EmailAddress,
CompanyName = tenant == null ? "Host tenant" : tenant.TenancyName
});
}
将返回null,因为我在移动应用中没有会话。
如何获取移动应用程序的租户ID?
我试图找到针对文档的解决方案,但没有运气
答案 0 :(得分:0)
您可以通过标题Abp.TenantId设置TenantId。还可以解决租户抛出自定义租户解决程序机制的问题。您需要实现将在请求处理之前运行的中间件,并将其添加到配置中。
Configuration.MultiTenancy.Resolvers.Add<DefaultTenantResolveContributor>();
您应该从接口继承:
ITenantResolveContributor