Skip to content

Commit

Permalink
PT-9274: add login on behalf Operator field in User Type (#33)
Browse files Browse the repository at this point in the history
* chore: update platfrom nuget packages

* chore: update ExperienceApi and Store module Nuget packages
  • Loading branch information
ksavosteev authored Oct 21, 2022
1 parent 349bf46 commit c88886a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
using System.Threading.Tasks;
using GraphQL.Resolvers;
using GraphQL.Types;
using MediatR;
using VirtoCommerce.ExperienceApiModule.Core.Helpers;
using VirtoCommerce.ExperienceApiModule.Core.Services;
using VirtoCommerce.Platform.Core.Security;
using VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates.Contact;
using VirtoCommerce.ProfileExperienceApiModule.Data.Queries;

namespace VirtoCommerce.ProfileExperienceApiModule.Data.Schemas
{
public class UserType : ObjectGraphType<ApplicationUser>
{
public UserType(IContactAggregateRepository contactAggregateRepository, IUserManagerCore userManagerCore)
public UserType(IContactAggregateRepository contactAggregateRepository, IUserManagerCore userManagerCore, IMediator mediator)
{
Field(x => x.AccessFailedCount);
Field(x => x.CreatedBy, true);
Expand Down Expand Up @@ -64,6 +66,25 @@ public UserType(IContactAggregateRepository contactAggregateRepository, IUserMan
Type = typeof(BooleanGraphType),
Resolver = new AsyncFieldResolver<ApplicationUser, bool>(context => userManagerCore.IsLockedOutAsync(context.Source)),
});

AddField(new FieldType
{
Name = "operator",
Type = GraphTypeExtenstionHelper.GetActualType<UserType>(),
Resolver = new AsyncFieldResolver<object>(async context =>
{
if (context.UserContext.TryGetValue("OperatorUserName", out var operatorUser))
{
var result = await mediator.Send(new GetUserQuery
{
UserName = operatorUser as string
});
return result;
}

return null;
})
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.CustomerModule.Core" Version="3.210.0" />
<PackageReference Include="VirtoCommerce.ExperienceApiModule.Core" Version="3.200.0" />
<PackageReference Include="VirtoCommerce.ExperienceApiModule.Core" Version="3.237.0" />
<PackageReference Include="VirtoCommerce.MarketingModule.Core" Version="3.200.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.257.0" />
<PackageReference Include="VirtoCommerce.Platform.Data" Version="3.257.0" />
<PackageReference Include="VirtoCommerce.Platform.Security" Version="3.257.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.259.0" />
<PackageReference Include="VirtoCommerce.Platform.Data" Version="3.259.0" />
<PackageReference Include="VirtoCommerce.Platform.Security" Version="3.259.0" />
<PackageReference Include="VirtoCommerce.PricingModule.Core" Version="3.200.0" />
<PackageReference Include="VirtoCommerce.StoreModule.Core" Version="3.200.0" />
<PackageReference Include="VirtoCommerce.StoreModule.Core" Version="3.207.0" />
<PackageReference Include="VirtoCommerce.CoreModule.Core" Version="3.203.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="VirtoCommerce.ExperienceApiModule.Core" Version="3.200.0" />
<PackageReference Include="VirtoCommerce.ExperienceApiModule.Core" Version="3.237.0" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/VirtoCommerce.ProfileExperienceApiModule.Web/module.manifest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<id>VirtoCommerce.ProfileExperienceApiModule</id>
<version>3.225.0</version>
<version-tag />
<platformVersion>3.257.0</platformVersion>
<platformVersion>3.259.0</platformVersion>
<title>Commerce Profile Experience API module</title>
<description />
<authors>
Expand All @@ -19,13 +19,13 @@
<assemblyFile>VirtoCommerce.ProfileExperienceApiModule.Web.dll</assemblyFile>
<moduleType>VirtoCommerce.ProfileExperienceApiModule.Web.Module, VirtoCommerce.ProfileExperienceApiModule.Web</moduleType>
<dependencies>
<dependency id="VirtoCommerce.ExperienceApi" version="3.200.0" />
<dependency id="VirtoCommerce.ExperienceApi" version="3.3.237.0" />
<dependency id="VirtoCommerce.Customer" version="3.210.0" />
<dependency id="VirtoCommerce.Store" version="3.200.0" />
<dependency id="VirtoCommerce.Store" version="3.207.0" />
<dependency id="VirtoCommerce.Marketing" version="3.200.0" />
</dependencies>
<groups>
<group>commerce</group>
</groups>
<useFullTypeNameInSwagger>false</useFullTypeNameInSwagger>
</module>
</module>

0 comments on commit c88886a

Please sign in to comment.